Skip to content

Commit

Permalink
MHR api latest schema updates (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett authored Mar 30, 2023
1 parent a9ea858 commit b1502ba
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 32 deletions.
10 changes: 7 additions & 3 deletions src/registry_schemas/example_data/mhr/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
NOTE = {
'documentType': 'CONV',
'documentId': 'REG01234',
'documentRegistrationNumber': '00402332',
'createDateTime': '2018-02-21T18:56:00+00:00',
'expiryDate': '2023-02-22T07:59:00+00:00',
'remarks': '',
Expand Down Expand Up @@ -600,10 +601,11 @@
},
'notes': [
{
'documentType': 'CONV',
'documentId': 'REG01234',
'documentType': 'EXRS',
'documentId': '80035947',
'documentRegistrationNumber': '00402332',
'createDateTime': '1995-02-21T18:56:00+00:00',
'remarks': '',
'remarks': 'HOME IS TO BE USED AS A STORAGE SHED',
'contactName': 'JOHNNY NUCLEO',
'contactAddress': {
'street': '940 BLANSHARD STREET',
Expand Down Expand Up @@ -783,6 +785,8 @@
'createDateTime': '2022-10-21T18:56:00+00:00',
'note': {
'documentType': 'REG_103',
'documentId': '80035947',
'documentRegistrationNumber': '00402332',
'remarks': 'test',
'expiryDate': '2022-11-21T08:00:00+00:00'
},
Expand Down
7 changes: 6 additions & 1 deletion src/registry_schemas/schemas/mhr/note.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
"documentId": {
"type": "string",
"maxLength": 8,
"description": "The unique document ID."
"description": "The unique document ID for the registration associated with the note."
},
"documentRegistrationNumber": {
"type": [ "string", "null" ],
"maxLength": 8,
"description": "The unique document registration number for the registration associated with the note."
},
"createDateTime": {
"type": "string",
Expand Down
6 changes: 3 additions & 3 deletions src/registry_schemas/schemas/mhr/registration.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"registrationType": {
"type": "string",
"maxLength": 20,
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND"]
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL"]
},
"status": {
"type": [ "string", "null" ],
"maxLength": 20,
"enum": ["ACTIVE", "DRAFT", "EXEMPT", "HISTORICAL"],
"description": "The status of the registration. ACTIVE - registered; DRAFT; EXEMPT; HISTORICAL - cancelled."
"enum": ["ACTIVE", "DRAFT", "EXEMPT", "FROZEN", "HISTORICAL"],
"description": "The status of the registration. ACTIVE - registered; DRAFT; FROZEN; EXEMPT; HISTORICAL - cancelled. FROZEN is a temporary state where only BC Registries staff can make a change to the manufactured home."
},
"clientReferenceId": {
"type": [ "string", "null" ],
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 @@ -34,8 +34,8 @@
"statusType": {
"type": "string",
"maxLength": 20,
"enum": ["ACTIVE", "DRAFT", "EXEMPT", "HISTORICAL"],
"description": "The status of the registration. ACTIVE - registered; DRAFT; EXEMPT; HISTORICAL - cancelled."
"enum": ["ACTIVE", "DRAFT", "EXEMPT", "FROZEN", "HISTORICAL"],
"description": "The status of the registration. ACTIVE - registered; DRAFT; EXEMPT; FROZEN; HISTORICAL - cancelled. FROZEN is a temporary state where only BC Registries staff can make a change to the manufactured home."
},
"path": {
"type": "string",
Expand Down
4 changes: 2 additions & 2 deletions src/registry_schemas/schemas/mhr/searchSummary.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"status": {
"type": "string",
"maxLength": 10,
"enum": ["ACTIVE", "EXEMPT", "HISTORICAL", "HISTORIC"],
"description": "The status of a manufactured home registration: one of ACTIVE, EXEMPT, or HISTORICAL. HISTORIC is deprecated (replaced by HISTORICAL)."
"enum": ["ACTIVE", "EXEMPT", "FROZEN", "HISTORICAL"],
"description": "The status of a manufactured home registration: one of ACTIVE, EXEMPT, FROZEN, or HISTORICAL."
},
"createDateTime": {
"type": "string",
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.3' # pylint: disable=invalid-name
__version__ = '1.7.4' # pylint: disable=invalid-name
3 changes: 3 additions & 0 deletions tests/unit/mhr/test_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
('Valid no address', True, 'type', '123456', True, True, 'remarks', 'contact', None),
('Valid no createTS', True, 'type', '123456', False, True, 'remarks', 'contact', ADDRESS),
('Valid no doc id', True, 'type', None, True, True, 'remarks', 'contact', ADDRESS),
('Valid no doc_reg num', True, 'type', '123456', True, True, 'remarks', 'contact', ADDRESS),
('Invalid no remarks', False, '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),
Expand Down Expand Up @@ -60,6 +61,8 @@ def test_note(desc, valid, type, doc_id, has_create, has_expiry, remarks, contac
del data['contactName']
if not address:
del data['contactAddress']
if desc == 'Valid no doc_reg num':
del data['documentRegistrationNumber']

is_valid, errors = validate(data, 'note', 'mhr')

Expand Down
5 changes: 4 additions & 1 deletion tests/unit/mhr/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
# testdata pattern is ({desc},{valid},{mhr},{status},{rev},{decv},{haso},{hasl},{hasd},{hasn},{hasdt},{hasp})
TEST_DATA_REG = [
('Valid request', True, None, None, 'ref', 50000, True, True, True, True, False, False),
('Valid response', True, '003456', 'EXEMPT', 'ref', 50000, True, True, True, True, True, True),
('Valid response ACTIVE', True, '003456', 'ACTIVE', 'ref', 50000, True, True, True, True, True, True),
('Valid response EXEMPT', True, '003456', 'EXEMPT', 'ref', 50000, True, True, True, True, True, True),
('Valid response HISTORICAL', True, '003456', 'HISTORICAL', 'ref', 50000, True, True, True, True, True, True),
('Valid response FROZEN', True, '003456', 'FROZEN', 'ref', 50000, True, True, True, True, True, True),
('Valid no ref', True, None, None, None, 50000, True, True, True, True, False, False),
('Valid no declared value', True, None, None, 'ref', None, True, True, True, True, False, False),
('Valid no notes', True, None, None, 'ref', 50000, True, True, True, False, False, False),
Expand Down
35 changes: 17 additions & 18 deletions tests/unit/mhr/test_registration_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
'path': '/mhr/api/v1/registrations/020000',
'createDateTime': '2021-06-03T22:58:45+00:00'
}
TEST_INVALID_STATUS_TYPE = {
'mhrNumber': '020000',
'statusType': 'X',
'path': '/mhr/api/v1/registrations/020000',
'createDateTime': '2021-06-03T22:58:45+00:00'
}
TEST_INVALID_MHR_NUMBER = {
'mhrNumber': '2020000',
'statusType': 'ACTIVE',
Expand Down Expand Up @@ -71,23 +65,28 @@
TEST_EMPTY_JSON = {
}

# testdata pattern is ({description}, {is valid}, {data})
# testdata pattern is ({description}, {is valid}, {data}, {status})
TEST_DATA = [
('All valid', True, TEST_VALID_ALL),
('Minimum valid', True, TEST_VALID_MINIMUM),
('Invalid status type', False, TEST_INVALID_STATUS_TYPE),
('Invalid mhr number length', False, TEST_INVALID_MHR_NUMBER),
('Invalid missing mhr num', False, TEST_INVALID_MISSING_MHR_NUMBER),
('Invalid missing status', False, TEST_INVALID_MISSING_STATUS),
('Invalid missing path', False, TEST_INVALID_MISSING_PATH),
('Invalid missing create_ts', False, TEST_INVALID_MISSING_CREATE_TS),
('No settings', False, TEST_EMPTY_JSON)
('All valid', True, TEST_VALID_ALL, 'ACTIVE'),
('Minimum valid', True, TEST_VALID_MINIMUM, 'ACTIVE'),
('Valid EXEMPT', True, TEST_VALID_MINIMUM, 'EXEMPT'),
('Valid HISTORICAL', True, TEST_VALID_MINIMUM, 'HISTORICAL'),
('Valid FROZEN', True, TEST_VALID_MINIMUM, 'FROZEN'),
('Invalid status type', False, TEST_VALID_MINIMUM, 'X'),
('Invalid mhr number length', False, TEST_INVALID_MHR_NUMBER, 'ACTIVE'),
('Invalid missing mhr num', False, TEST_INVALID_MISSING_MHR_NUMBER, 'ACTIVE'),
('Invalid missing status', False, TEST_INVALID_MISSING_STATUS, None),
('Invalid missing path', False, TEST_INVALID_MISSING_PATH, 'ACTIVE'),
('Invalid missing create_ts', False, TEST_INVALID_MISSING_CREATE_TS, 'ACTIVE'),
('No settings', False, TEST_EMPTY_JSON, None)
]


@pytest.mark.parametrize('desc,valid,data', TEST_DATA)
def test_registration_summary(desc, valid, data):
@pytest.mark.parametrize('desc,valid,data,status', TEST_DATA)
def test_registration_summary(desc, valid, data, status):
"""Assert that the schema is performing as expected for a registration summary."""
if status:
data['statusType'] = status
is_valid, errors = validate(data, 'registrationSummary', 'mhr')

if errors:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mhr/test_search_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
('ACTIVE', True),
('EXEMPT', True),
('HISTORICAL', True),
('HISTORIC', True),
('FROZEN', True),
('XX', False)
]
# testdata pattern is ({is valid}, {has_mrh}, {has_status}, {has_base})
Expand Down

0 comments on commit b1502ba

Please sign in to comment.