diff --git a/setup.cfg b/setup.cfg index 7a22d23..3384cf7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/src/registry_schemas/flask/schema_services.py b/src/registry_schemas/flask/schema_services.py index 6b0dd50..a6e2b0f 100644 --- a/src/registry_schemas/flask/schema_services.py +++ b/src/registry_schemas/flask/schema_services.py @@ -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. diff --git a/src/registry_schemas/schemas/mhr/note.json b/src/registry_schemas/schemas/mhr/note.json index 49d71f4..9734f29 100644 --- a/src/registry_schemas/schemas/mhr/note.json +++ b/src/registry_schemas/schemas/mhr/note.json @@ -7,7 +7,7 @@ "documentType": { "type": "string", "minLength": 1, - "maxLength": 10, + "maxLength": 20, "description": "The note document type code." }, "documentId": { @@ -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": { diff --git a/src/registry_schemas/schemas/mhr/owner.json b/src/registry_schemas/schemas/mhr/owner.json index ee68718..e8c340f 100644 --- a/src/registry_schemas/schemas/mhr/owner.json +++ b/src/registry_schemas/schemas/mhr/owner.json @@ -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":[ diff --git a/src/registry_schemas/schemas/mhr/registration.json b/src/registry_schemas/schemas/mhr/registration.json index 920dc73..d3f97f8 100644 --- a/src/registry_schemas/schemas/mhr/registration.json +++ b/src/registry_schemas/schemas/mhr/registration.json @@ -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": { diff --git a/src/registry_schemas/schemas/mhr/registrationSummary.json b/src/registry_schemas/schemas/mhr/registrationSummary.json index 9100035..ed9ca8d 100644 --- a/src/registry_schemas/schemas/mhr/registrationSummary.json +++ b/src/registry_schemas/schemas/mhr/registrationSummary.json @@ -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": { diff --git a/src/registry_schemas/version.py b/src/registry_schemas/version.py index c164781..dc67677 100644 --- a/src/registry_schemas/version.py +++ b/src/registry_schemas/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '1.8.3' # pylint: disable=invalid-name +__version__ = '1.8.4' # pylint: disable=invalid-name diff --git a/tests/unit/mhr/test_note.py b/tests/unit/mhr/test_note.py index 926f194..b2d5110 100644 --- a/tests/unit/mhr/test_note.py +++ b/tests/unit/mhr/test_note.py @@ -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) ] diff --git a/tests/unit/mhr/test_owner.py b/tests/unit/mhr/test_owner.py index 4006f48..01b51c5 100644 --- a/tests/unit/mhr/test_owner.py +++ b/tests/unit/mhr/test_owner.py @@ -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') ] @@ -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: @@ -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: