Skip to content

Commit

Permalink
Update mhr owner schema. (#44)
Browse files Browse the repository at this point in the history
* Update mhr owner schema.

Signed-off-by: Doug Lovett <doug@diamante.ca>

* Update mhr owner schema.

Signed-off-by: Doug Lovett <doug@diamante.ca>

---------

Signed-off-by: Doug Lovett <doug@diamante.ca>
  • Loading branch information
doug-lovett authored Feb 22, 2023
1 parent 0d5d1ea commit 0894c79
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/registry_schemas/schemas/mhr/owner.json
Original file line number Diff line number Diff line change
Expand Up @@ -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":[
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '1.7.1' # pylint: disable=invalid-name
__version__ = '1.7.2' # pylint: disable=invalid-name
36 changes: 36 additions & 0 deletions tests/unit/mhr/test_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 0894c79

Please sign in to comment.