Skip to content

Commit

Permalink
MHR owner schema add corpNum, deathCorpNum (#57)
Browse files Browse the repository at this point in the history
* MHR owner schema add corpNum, deathCorpNum

Signed-off-by: Doug Lovett <[email protected]>

* Fix pylint unrecognized option error 1

Signed-off-by: Doug Lovett <[email protected]>

* Fix pylint unrecognized option error 2

Signed-off-by: Doug Lovett <[email protected]>

* Fix new pylint  3.7 R6301: Method could be a function 3

Signed-off-by: Doug Lovett <[email protected]>

---------

Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett authored Oct 5, 2023
1 parent acad00e commit 68e27cc
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 20 deletions.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ load-plugins=pylint.extensions.no_self_use

[pylint]
ignore=migrations,test
max_line_length=120
max-line-length=120
notes=FIXME,XXX,TODO
ignored-modules=
ignored-classes=
disable=C0301,W0511,R0801,R0902
disable=C0301,W0511,R0801,R0902,R6301

[isort]
line_length=120
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/flask/schema_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def init_app(self, app):
self.app = app
app.teardown_appcontext(self.teardown)

def teardown(self, exception): # pylint: disable=unused-argument,no-self-use
def teardown(self, exception): # pylint: disable=unused-argument
"""Clean up whatever the extension has created as part of the Flask teardown lifecycle.
pylint added so that the Flask method signature matches.
Expand Down
4 changes: 2 additions & 2 deletions src/registry_schemas/schemas/mhr/note.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"documentType": {
"type": "string",
"minLength": 1,
"maxLength": 10,
"maxLength": 20,
"description": "The note document type code."
},
"documentId": {
Expand Down Expand Up @@ -61,7 +61,7 @@
"cancelledDocumentType": {
"type": "string",
"minLength": 1,
"maxLength": 10,
"maxLength": 20,
"description": "Conditionally included with the NCAN document type as the document type for the unit note registration that has been cancelled."
},
"cancelledDocumentDescription": {
Expand Down
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 @@ -63,6 +63,16 @@
"type": "string",
"format": "date-time",
"description": "Include only for transfer due to death registration types when the owner in the deleteOwnerGroups is deceased. Must be in the past when the registration is submitted."
},
"corpNumber": {
"type": "string",
"maxLength": 20,
"description": "Optional business company number. Include in a request if available and the added owner is a business/organziation."
},
"deathCorpNumber": {
"type": "string",
"maxLength": 20,
"description": "Include only for transfer due to death registration types when the owner is in the deleteOwnerGroups, not added, and is a business/organization."
}
},
"oneOf":[
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/schemas/mhr/registration.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"frozenDocumentType": {
"type": "string",
"minLength": 1,
"maxLength": 10,
"maxLength": 20,
"description": "If the status is FROZEN, frozenDocumentType is conditionally included in the response as the document type of the registration that put the home in a frozen or locked state."
},
"payment": {
Expand Down
4 changes: 2 additions & 2 deletions src/registry_schemas/schemas/mhr/registrationSummary.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@
"frozenDocumentType": {
"type": "string",
"minLength": 1,
"maxLength": 10,
"maxLength": 20,
"description": "If the statusType is FROZEN, frozenDocumentType is conditionally included in the response as the document type of the registration that put the home in a frozen or locked state."
},
"cancelledDocumentType": {
"type": "string",
"minLength": 1,
"maxLength": 10,
"maxLength": 20,
"description": "Conditionally included with the NCAN document type registration as the document type for the unit note registration that has been cancelled."
},
"cancelledDocumentDescription": {
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.8.3' # pylint: disable=invalid-name
__version__ = '1.8.4' # pylint: disable=invalid-name
2 changes: 1 addition & 1 deletion tests/unit/mhr/test_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
('Valid empty remarks', True, 'type', '123456', True, True, ' ', 'contact', ADDRESS),
('Valid no remarks', True, 'type', '123456', True, True, None, 'contact', ADDRESS),
('Invalid no type', False, None, '123456', True, True, 'remarks', 'contact', ADDRESS),
('Invalid type too long', False, '01234567891', '123456', True, True, 'remarks', 'contact', ADDRESS),
('Invalid type too long', False, '012345678901234567891', '123456', True, True, 'remarks', 'contact', ADDRESS),
('Invalid doc id too long', False, '1234', '123456789', True, True, 'remarks', 'contact', ADDRESS),
('Invalid contact too long', False, '1234', '123456', True, True, 'remarks', LONG_NAME, ADDRESS)
]
Expand Down
52 changes: 42 additions & 10 deletions tests/unit/mhr/test_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,21 @@
(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')
# testdata pattern is ({valid}, {party_type}, {cert_number}, {death_ts}, {death_corp_num})
TEST_DATA_DEATH = [
(True, 'OWNER_BUS', None, None, None),
(True, 'OWNER_IND', None, None, None),
(True, 'OWNER_BUS', None, '2021-02-21T18:56:00+00:00', '01234567890123456789'),
(True, 'OWNER_IND', '01234567890123456789', '2021-02-21T18:56:00+00:00', None),
(False, 'OWNER_BUS', None, '2021-02-21T18:56:00+00:00', '012345678901234567891'),
(False, 'OWNER_IND', '012345678901234567891', '2021-02-21T18:56:00+00:00', None)
]
# testdata pattern is ({valid}, {party_type}, {corp_num})
TEST_DATA_CORP_NUM = [
(True, 'OWNER_BUS', None),
(True, 'OWNER_IND', None),
(True, 'OWNER_BUS', '01234567890123456789'),
(False, 'OWNER_BUS', '012345678901234567891')
]


Expand Down Expand Up @@ -120,8 +127,8 @@ def test_owner_party_type(valid, party_type, party_desc):
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):
@pytest.mark.parametrize('valid,party_type,cert_number,death_ts,death_corp_num', TEST_DATA_DEATH)
def test_owner_death_cert(valid, party_type, cert_number, death_ts, death_corp_num):
"""Assert that the schema is performing as expected."""
data = copy.deepcopy(OWNER)
if party_type:
Expand All @@ -134,7 +141,32 @@ def test_owner_death_cert(valid, party_type, cert_number, death_ts):
data['deathDateTime'] = death_ts
elif data.get('deathDateTime'):
del data['deathDateTime']
if death_corp_num:
data['deathCorpNumber'] = death_corp_num
elif data.get('deathCorpNumber'):
del data['deathCorpNumber']
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


@pytest.mark.parametrize('valid,party_type,corp_num', TEST_DATA_CORP_NUM)
def test_owner_corp_num(valid, party_type, corp_num):
"""Assert that the schema is performing as expected."""
data = copy.deepcopy(OWNER)
if party_type:
data['partyType'] = party_type
if corp_num:
data['corpNumber'] = corp_num
elif data.get('corpNumber'):
del data['corpNumber']
is_valid, errors = validate(data, 'owner', 'mhr')

if errors:
Expand Down

0 comments on commit 68e27cc

Please sign in to comment.