Skip to content

Commit

Permalink
Latest MHR API transport permit schema changes
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett committed Dec 19, 2023
1 parent cd8d965 commit 251c013
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/registry_schemas/schemas/mhr/adminRegistration.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"registrationType": {
"type": "string",
"maxLength": 20,
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "MHREG_CONVERSION", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL", "REG_STAFF_ADMIN"]
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "MHREG_CONVERSION", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL", "REG_STAFF_ADMIN", "AMENDMENT"]
},
"clientReferenceId": {
"type": [ "string", "null" ],
Expand All @@ -52,7 +52,7 @@
"documentType": {
"type": "string",
"maxLength": 20 ,
"enum": ["ADDI", "ATTA", "COMP", "CONF", "COUR", "DNCH", "EXRE", "FZE", "INTE", "INTW", "MAID", "MAIL", "MARR", "MEAM", "NAMV", "NCAN", "NRED", "PDEC", "PUBA", "REBU", "REGC", "STAT", "THAW", "WHAL"]
"enum": ["ADDI", "ATTA", "COMP", "CONF", "COUR", "DNCH", "EXRE", "FZE", "INTE", "INTW", "MAID", "MAIL", "MARR", "MEAM", "NAMV", "NCAN", "NRED", "PDEC", "PUBA", "REBU", "REGC", "STAT", "THAW", "WHAL", "AMEND_PERMIT", "CANCEL_PERMIT"]
},
"updateDocumentId": {
"type": [ "string", "null" ],
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/schemas/mhr/noteRegistration.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"registrationType": {
"type": "string",
"maxLength": 20,
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "MHREG_CONVERSION", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL", "REG_STAFF_ADMIN"]
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "MHREG_CONVERSION", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL", "REG_STAFF_ADMIN", "AMENDMENT"]
},
"clientReferenceId": {
"type": [ "string", "null" ],
Expand Down
23 changes: 22 additions & 1 deletion src/registry_schemas/schemas/mhr/registration.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"registrationType": {
"type": "string",
"maxLength": 20,
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "MHREG_CONVERSION", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL", "REG_STAFF_ADMIN"]
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "MHREG_CONVERSION", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL", "REG_STAFF_ADMIN", "AMENDMENT"]
},
"status": {
"type": [ "string", "null" ],
Expand Down Expand Up @@ -103,6 +103,27 @@
"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."
},
"permitStatus": {
"type": "string",
"maxLength": 20,
"enum": ["ACTIVE", "EXPIRED", "CANCELLED"],
"description": "The status of the most recent transport permit registration."
},
"permitRegistrationNumber": {
"type": "string",
"maxLength": 8,
"description": "The document registration number of the most recent transport permit registration."
},
"permitDateTime": {
"type": "string",
"format": "date-time",
"description": "The timestamp of the most recent transport permit registration."
},
"permitExpiryDateTime": {
"type": "string",
"format": "date-time",
"description": "The expiry timestamp of the most recent transport permit registration."
},
"payment": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/paymentReference"
}
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/schemas/mhr/registrationSummary.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"registrationType": {
"type": "string",
"maxLength": 20,
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "MHREG_CONVERSION", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL", "REG_STAFF_ADMIN"]
"enum": ["DECAL_REPLACE", "EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "MHREG_CONVERSION", "PERMIT", "PERMIT_EXTENSION", "TRANS", "TRAND", "TRANS_AFFIDAVIT", "TRANS_ADMIN", "TRANS_WILL", "REG_STAFF_ADMIN", "AMENDMENT"]
},
"hasCaution": {
"type": "boolean",
Expand Down
6 changes: 5 additions & 1 deletion src/registry_schemas/schemas/mhr/transportPermit.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"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", "MHREG_CONVERSION", "AMENDMENT"]
},
"clientReferenceId": {
"type": [ "string", "null" ],
Expand Down Expand Up @@ -67,6 +67,10 @@
"type": "boolean",
"description": "Set to true if either the new location type is MH_PARK and the move is not within the same park, or the new location type is STRATA, RESERVE, or OTHER."
},
"amendment": {
"type": "boolean",
"description": "True if the registration amends an existing transport permit location."
},
"payment": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/paymentReference"
}
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.7' # pylint: disable=invalid-name
__version__ = '1.8.8' # pylint: disable=invalid-name
8 changes: 7 additions & 1 deletion tests/unit/mhr/test_admin_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
('Valid request NCAN', True, 'NCAN', True, True, None, None),
('Valid request REGC', True, 'REGC', True, True, None, None),
('Valid request STAT', True, 'STAT', True, True, None, None),
('Valid request CANCEL_PERMIT', True, 'CANCEL_PERMIT', True, True, None, None),
('Valid response CANCEL_PERMIT', True, 'CANCEL_PERMIT', True, True, None, None),
('Valid response', True, 'THAW', True, False, '1234', 'JOHN SMITH'),
('Invalid client ref', False, 'NRED', True, True, LONG_CLIENT_REF, None),
('Invalid attention', False, 'EXRE', True, True, None, LONG_CLIENT_REF),
Expand Down Expand Up @@ -63,8 +65,12 @@ def test_note_registration(desc, valid, doc_type, has_sub, is_request, client_re
del data['registrationType']
if desc == 'Invalid update doc id':
data['updateDocumentId'] = '123456789'
elif desc in ('Valid request REGC', 'Valid request STAT'):
elif desc in ('Valid request REGC', 'Valid request STAT',
'Valid request CANCEL_PERMIT', 'Valid response CANCEL_PERMIT'):
data['location'] = copy.deepcopy(LOCATION)
if desc in ('Valid request CANCEL_PERMIT', 'Valid response CANCEL_PERMIT'):
data['documentType'] = 'CANCEL_PERMIT'
data['registrationType'] = 'REG_STAFF_ADMIN'
is_valid, errors = validate(data, 'adminRegistration', 'mhr')

if errors:
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/mhr/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

LONG_CLIENT_REF = '012345678901234567890123456789012345678901234567890'
LONG_ATTENTION_REF = LONG_CLIENT_REF
TEST_TS = '2024-01-31T08:00:00+00:00'

# testdata pattern is ({desc},{valid},{mhr},{status},{rev},{decv},{haso},{hasl},{hasd},{hasn},{hasdt},{hasp})
TEST_DATA_REG = [
Expand Down Expand Up @@ -136,6 +137,14 @@
('Invalid data type int', False, 20),
('Invalid data type str', False, 'junk')
]
# testdata pattern is ({desc}, {valid}, {status}, {reg_num})
TEST_DATA_PERMIT = [
('Valid', True, 'ACTIVE', '88888888'),
('Valid expired', True, 'ACTIVE', '88888888'),
('Valid cancelled', True, 'ACTIVE', '88888888'),
('Invalid status', False, 'JUNK', '88888888'),
('Invalid reg number', False, 'ACTIVE', '888888889')
]


@pytest.mark.parametrize('desc,valid,mhr,status,ref,decv,haso,hasl,hasd,hasn,hasdt,hasp', TEST_DATA_REG)
Expand Down Expand Up @@ -246,3 +255,19 @@ def test_registration_own_land(desc, valid, value):
assert is_valid
else:
assert not is_valid


@pytest.mark.parametrize('desc,valid,status,reg_num', TEST_DATA_PERMIT)
def test_registration_permit(desc, valid, status, reg_num):
"""Assert that the schema is performing as expected."""
data = copy.deepcopy(REGISTRATION)
data['permitStatus'] = status
data['permitRegistrationNumber'] = reg_num
data['permitDateTime'] = TEST_TS
data['permitExpiryDateTime'] = TEST_TS
is_valid, errors = validate(data, 'registration', 'mhr')

if valid:
assert is_valid
else:
assert not is_valid
7 changes: 7 additions & 0 deletions tests/unit/mhr/test_transport_permit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# testdata pattern is ({desc},{valid},{sub_party},{new},{is_request},{client_ref})
TEST_DATA = [
('Valid request', True, True, True, True, None),
('Valid amendment request', True, True, True, True, None),
('Valid amendment response', True, True, True, True, None),
('Valid response', True, True, True, False, '1234'),
('Invalid client ref', False, True, True, True, LONG_CLIENT_REF),
('Invalid missing sub party', False, False, True, True, '1234'),
Expand All @@ -35,6 +37,11 @@
def test_permit(desc, valid, sub_party, new, is_request, client_ref):
"""Assert that the schema is performing as expected."""
data = copy.deepcopy(PERMIT)
if desc == 'Valid amendment request':
data['amendment'] = True
elif desc == 'Valid amendment response':
data['amendment'] = True
data['registrationType'] = 'AMENDMENT'
if not sub_party:
del data['submittingParty']
if client_ref:
Expand Down

0 comments on commit 251c013

Please sign in to comment.