From 0894c7994f77bbde3335e0fe3e6a5025f888e93f Mon Sep 17 00:00:00 2001 From: Doug Lovett Date: Wed, 22 Feb 2023 08:50:10 -0800 Subject: [PATCH] Update mhr owner schema. (#44) * Update mhr owner schema. Signed-off-by: Doug Lovett * Update mhr owner schema. Signed-off-by: Doug Lovett --------- Signed-off-by: Doug Lovett --- src/registry_schemas/schemas/mhr/owner.json | 10 ++++++ src/registry_schemas/version.py | 2 +- tests/unit/mhr/test_owner.py | 36 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/registry_schemas/schemas/mhr/owner.json b/src/registry_schemas/schemas/mhr/owner.json index 598d051..4690fda 100644 --- a/src/registry_schemas/schemas/mhr/owner.json +++ b/src/registry_schemas/schemas/mhr/owner.json @@ -53,6 +53,16 @@ "type": "string", "maxLength": 70, "description": "The organization or individual name suffix." + }, + "deathCertificateNumber": { + "type": "string", + "maxLength": 20, + "description": "Include only for a transfer due to death registration types when the owner in the deleteOwnerGroups is deceased." + }, + "deathDateTime": { + "type": "string", + "format": "date-time", + "description": "Include only for a transfer due to death registration types when the owner in the deleteOwnerGroups is deceased. Must be in the past when the registration is submitted." } }, "oneOf":[ diff --git a/src/registry_schemas/version.py b/src/registry_schemas/version.py index 2bc20a4..d60de70 100644 --- a/src/registry_schemas/version.py +++ b/src/registry_schemas/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '1.7.1' # pylint: disable=invalid-name +__version__ = '1.7.2' # pylint: disable=invalid-name diff --git a/tests/unit/mhr/test_owner.py b/tests/unit/mhr/test_owner.py index 1183406..9b6f304 100644 --- a/tests/unit/mhr/test_owner.py +++ b/tests/unit/mhr/test_owner.py @@ -52,6 +52,15 @@ (True, 'ADMINISTRATOR', 'ADMINISTRATOR'), (False, 'JUNK', None) ] +# testdata pattern is ({valid}, {party_type}, {cert_number}, {death_ts}) +TEST_DATA_DEATH_CERTIFICATE = [ + (True, 'OWNER_BUS', None, None), + (True, 'OWNER_IND', None, None), + (True, 'OWNER_BUS', '01234567890123456789', '2021-02-21T18:56:00+00:00'), + (True, 'OWNER_IND', '01234567890123456789', '2021-02-21T18:56:00+00:00'), + (False, 'OWNER_BUS', '012345678901234567891', '2021-02-21T18:56:00+00:00'), + (False, 'OWNER_IND', '012345678901234567891', '2021-02-21T18:56:00+00:00') +] @pytest.mark.parametrize('desc,valid,org,individual,address,type,status,phone,suffix', TEST_DATA_OWNER) @@ -108,3 +117,30 @@ def test_owner_party_type(valid, party_type, party_desc): assert is_valid else: assert not is_valid + + +@pytest.mark.parametrize('valid,party_type,cert_number,death_ts', TEST_DATA_DEATH_CERTIFICATE) +def test_owner_death_cert(valid, party_type, cert_number, death_ts): + """Assert that the schema is performing as expected.""" + data = copy.deepcopy(OWNER) + if party_type: + data['partyType'] = party_type + if cert_number: + data['deathCertificateNumber'] = cert_number + elif data.get('deathCertificateNumber'): + del data['deathCertificateNumber'] + if death_ts: + data['deathDateTime'] = death_ts + elif data.get('deathDateTime'): + del data['deathDateTime'] + + is_valid, errors = validate(data, 'owner', 'mhr') + + if errors: + for err in errors: + print(err.message) + + if valid: + assert is_valid + else: + assert not is_valid