From ce0f60bc02ab134b563510da40ffb65a85bd18f5 Mon Sep 17 00:00:00 2001 From: Lindsay Richter Date: Mon, 27 Oct 2025 10:58:08 -0400 Subject: [PATCH] Make country_code optional for Account and Contact --- paperless/objects/customers.py | 8 ++++++-- tests/unit/test_contacts.py | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/paperless/objects/customers.py b/paperless/objects/customers.py index e7f3217..b392ad6 100644 --- a/paperless/objects/customers.py +++ b/paperless/objects/customers.py @@ -127,12 +127,14 @@ class Account( _json_encoder = AccountEncoder name: str = attr.ib(validator=attr.validators.instance_of(str)) - country_code: str = attr.ib(validator=attr.validators.instance_of((str, object))) # not required for instantiation billing_addresses = attr.ib( default=[], converter=optional_convert(convert_iterable(BillingAddress)) ) + country_code: str = attr.ib( + default=NO_UPDATE, validator=attr.validators.instance_of((str, object)) + ) created = attr.ib( default=NO_UPDATE, validator=(attr.validators.instance_of((str, object))) ) @@ -312,12 +314,14 @@ class Contact( email: str = attr.ib(validator=attr.validators.instance_of(str)) first_name: str = attr.ib(validator=attr.validators.instance_of(str)) last_name: str = attr.ib(validator=attr.validators.instance_of(str)) - country_code: str = attr.ib(validator=attr.validators.instance_of((str, object))) # not required for instantiation address = attr.ib( default=NO_UPDATE, converter=optional_convert(convert_cls(Address)) ) + country_code: str = attr.ib( + default=NO_UPDATE, validator=attr.validators.instance_of((str, object)) + ) created = attr.ib( default=NO_UPDATE, validator=(attr.validators.instance_of((str, object))) ) diff --git a/tests/unit/test_contacts.py b/tests/unit/test_contacts.py index 745181c..6b632bc 100644 --- a/tests/unit/test_contacts.py +++ b/tests/unit/test_contacts.py @@ -19,6 +19,15 @@ def setUp(self): with open('tests/unit/mock_data/contact.json') as data_file: self.mock_contact_json = json.load(data_file) + def test_create_contact_obj_with_only_required_args(self): + # should not raise any error + Contact( + account_id = 1, + email = "contact@paperlessparts.com", + first_name = "Contact", + last_name = "Paperless" + ) + def test_get_contact(self): self.client.get_resource = MagicMock(return_value=self.mock_contact_json) c = Contact.get(1) @@ -94,6 +103,10 @@ def setUp(self): with open('tests/unit/mock_data/account.json') as data_file: self.mock_account_json = json.load(data_file) + def test_create_account_with_only_required_args(self): + # should not raise any error + Account(name="Account Name") + def test_get_account(self): self.client.get_resource = MagicMock(return_value=self.mock_account_json) a = Account.get(1)