From 3b55629ff95f3a2e857ca0774f14b46fcceec82c Mon Sep 17 00:00:00 2001 From: Hongjing <60866283+chenhongjing@users.noreply.github.com> Date: Wed, 11 Oct 2023 15:32:30 -0700 Subject: [PATCH] 17796 Allow firm registration for single name user/account (#144) * 17796 Signed-off-by: Hongjing Chen * fix some tests Signed-off-by: Hongjing Chen * fix-2 Signed-off-by: Hongjing Chen * update version = 2.18.12 Signed-off-by: Hongjing Chen * update required fields Signed-off-by: Hongjing Chen * fix-3 Signed-off-by: Hongjing Chen * update version=2.18.13 Signed-off-by: Hongjing Chen --------- Signed-off-by: Hongjing Chen --- src/registry_schemas/schemas/party.json | 26 +++++++++++++++++++++++-- src/registry_schemas/version.py | 2 +- tests/unit/test_registration.py | 25 ++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/registry_schemas/schemas/party.json b/src/registry_schemas/schemas/party.json index fb45b20..ec73abf 100644 --- a/src/registry_schemas/schemas/party.json +++ b/src/registry_schemas/schemas/party.json @@ -48,7 +48,7 @@ "properties": { "partyType": { "const": "person" } }, - "required": ["firstName", "lastName"] + "required": ["lastName"] }, { "properties": { @@ -119,7 +119,29 @@ "officer", "roles", "mailingAddress" - ] + ], + "if": { + "properties":{ + "officer": { + "type": "object", + "properties": { + "partyType": { "enum": ["person"] } + }, + "required":["partyType"] + } + } + }, + "then": { + "properties": { + "officer": { + "type": "object", + "properties": { + "lastName": { "minLength": 1 } + }, + "required": ["lastName"] + } + } + } } }, "properties": { diff --git a/src/registry_schemas/version.py b/src/registry_schemas/version.py index 75c0e3b..80a6da5 100644 --- a/src/registry_schemas/version.py +++ b/src/registry_schemas/version.py @@ -23,4 +23,4 @@ """ -__version__ = '2.18.12' # pylint: disable=invalid-name +__version__ = '2.18.13' # pylint: disable=invalid-name diff --git a/tests/unit/test_registration.py b/tests/unit/test_registration.py index 2ef5acd..9d6c19d 100644 --- a/tests/unit/test_registration.py +++ b/tests/unit/test_registration.py @@ -229,3 +229,28 @@ def test_validate_invalid_court_orders(invalid_court_order): print(errors) assert not is_valid + +@pytest.mark.parametrize( + 'first_name, last_name, expected', [ + ('Joe', 'Swanson', True), + ('', 'Swanson', True), + ('Joe', '', False), + ('', '', False), + ('', 'asdfghasdfghasdfghasdfghasdfghasdfgh', False) + ] +) +def test_validate_single_name(first_name, last_name, expected): + registration_json = copy.deepcopy(REGISTRATION) + registration_json['parties'][0]['officer']['firstName'] = first_name + registration_json['parties'][0]['officer']['lastName'] = last_name + del registration_json['parties'][0]['roles'][1] + legal_filing = {'registration': registration_json} + + is_valid, errors = validate(legal_filing, 'registration') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid == expected