Skip to content

Commit

Permalink
MHR QS dealer schema updates (#65)
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett authored Nov 12, 2024
1 parent 512fccd commit 45058d6
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 14 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 @@ -18,7 +18,7 @@
},
"documentId": {
"type": [ "string", "null" ],
"maxLength": 8,
"maxLength": 10,
"minLength": 8,
"description": "Unique registration document ID/number assigned by the Manufactured Home Registry."
},
Expand Down Expand Up @@ -62,7 +62,7 @@
},
"updateDocumentId": {
"type": [ "string", "null" ],
"maxLength": 8,
"maxLength": 10,
"description": "Only required with NRED and COUR document type requests. It is the document ID of a previously created registration that is being cancelled or updated."
},
"note": {
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/schemas/mhr/exemption.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"documentId": {
"type": [ "string", "null" ],
"maxLength": 8,
"maxLength": 10,
"minLength": 8,
"description": "Unique registration document ID/number assigned by the Manufactured Home Registry."
},
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/schemas/mhr/note.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"documentId": {
"type": "string",
"maxLength": 8,
"maxLength": 10,
"description": "The unique document ID for the registration associated with the note."
},
"documentRegistrationNumber": {
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 @@ -38,7 +38,7 @@
},
"cancelDocumentId": {
"type": [ "string", "null" ],
"maxLength": 8,
"maxLength": 10,
"description": "Only included in requests for the NCAN document type, the document ID of the previously created unit note registration that is being cancelled."
},
"payment": {
Expand Down
8 changes: 8 additions & 0 deletions src/registry_schemas/schemas/mhr/qualifiedSupplier.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
"termsAccepted": {
"type": "boolean",
"description": "Included in the POST response to indicate the terms of agreement document has been accepted by the account submitting the request."
},
"confirmRequirements": {
"type": "boolean",
"description": "Applies to QS dealers: indicates that the dealer has confirmed acceptance of additional requirements regarding registrations."
},
"locationAddress": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/address",
"description": "Applies to QS dealers: specifies the location address for transport permit related registrations."
}
},
"anyOf":[
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 @@ -17,7 +17,7 @@
},
"documentId": {
"type": [ "string", "null" ],
"maxLength": 8,
"maxLength": 10,
"minLength": 8,
"description": "Unique registration document ID/number required for new registrations as a reference to the decal; assigned by the Manufactured Home Registry."
},
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 @@ -12,7 +12,7 @@
},
"documentId": {
"type": [ "string", "null" ],
"maxLength": 8,
"maxLength": 10,
"minLength": 8,
"description": "Unique registration document ID/number assigned by the Manufactured Home Registry."
},
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/schemas/mhr/transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"documentId": {
"type": [ "string", "null" ],
"maxLength": 8,
"maxLength": 10,
"minLength": 8,
"description": "Unique registration document ID/number assigned by the Manufactured Home Registry."
},
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/schemas/mhr/transportPermit.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"documentId": {
"type": [ "string", "null" ],
"maxLength": 8,
"maxLength": 10,
"minLength": 8,
"description": "Unique registration document ID/number assigned by the Manufactured Home Registry."
},
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.11' # pylint: disable=invalid-name
__version__ = '1.8.12' # pylint: disable=invalid-name
2 changes: 1 addition & 1 deletion tests/unit/mhr/test_admin_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_admin_registration(desc, valid, doc_type, has_sub, is_request, client_r
del data['payment']
del data['registrationType']
if desc == 'Invalid update doc id':
data['updateDocumentId'] = '123456789'
data['updateDocumentId'] = '01234567890'
elif desc in ('Valid request STAT',
'Valid request CANCEL_PERMIT',
'Valid response CANCEL_PERMIT'):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mhr/test_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
('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, '012345678901234567891', '123456', True, True, 'remarks', 'contact', ADDRESS),
('Invalid doc id too long', False, '1234', '123456789', True, True, 'remarks', 'contact', ADDRESS),
('Invalid doc id too long', False, '1234', '01234567890', True, True, 'remarks', 'contact', ADDRESS),
('Invalid contact too long', False, '1234', '123456', True, True, 'remarks', LONG_NAME, ADDRESS)
]
# testdata pattern is ({valid},{reason},{other})
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mhr/test_note_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
TEST_DATA_CANCEL = [
('Valid request', True, '12345678', True, None, None, None),
('Valid response', True, None, False, 'CAU', '00545678', 'NOTICE OF CAUTION'),
('Invalid request doc id', False, '123456789', True, None, None, None)
('Invalid request doc id', False, '01234567890', True, None, None, None)
]


Expand Down
43 changes: 43 additions & 0 deletions tests/unit/mhr/test_qualified_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
NAME_50 = '01234567890123456789012345678901234567890123456789'
BUS_MAX_LENGTH = NAME_50 + NAME_50 + NAME_50
DBA_MAX_LENGTH = NAME_50 + NAME_50 + NAME_50
LOCATION_ADDRESS = {
'street': '520 Location St',
'city': 'Victoria',
'region': 'BC',
'country': 'CA',
'postalCode': 'V8S 2V4'
}


# testdata pattern is ({desc},{valid},{bus},{dba},{phone},{email},{has_address})
TEST_DATA_SUPPLIER = [
Expand All @@ -36,6 +44,41 @@
('Invalid dba name', False, 'BUS NAME', DBA_MAX_LENGTH + 'X', None, None, True),
('Invalid email', False, 'BUS NAME', None, None, 'invalid format', True)
]
# testdata pattern is ({desc},{valid},{confirm_req},{loc_address})
TEST_DATA_DEALER = [
('Valid all', True, True, LOCATION_ADDRESS),
('Valid no confirm req', True, None, LOCATION_ADDRESS),
('Valid confirm req false', True, False, LOCATION_ADDRESS),
('Valid no loc address', True, True, None),
('Invalid address', False, True, LOCATION_ADDRESS)
]


@pytest.mark.parametrize('desc,valid, confirm_req, loc_address', TEST_DATA_DEALER)
def test_dealer(desc, valid, confirm_req, loc_address):
"""Assert that the schema is performing as expected for dealer information."""
data = copy.deepcopy(QUALIFIED_SUPPLIER)
del data['phoneExtension']
if confirm_req is not None:
if confirm_req:
data['confirmRequirements'] = True
else:
data['confirmRequirements'] = False
if loc_address:
address = copy.deepcopy(loc_address)
if desc == 'Invalid address':
del address['postalCode']
data['locationAddress'] = address

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

if errors:
for err in errors:
print(err.message)
if valid:
assert is_valid
else:
assert not is_valid


@pytest.mark.parametrize('desc,valid,bus_name,dba_name,phone,email,has_address', TEST_DATA_SUPPLIER)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mhr/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_registration(desc, valid, mhr, status, ref, decv, haso, hasl, hasd, has
else:
data['declaredValue'] = decv
if desc == 'Invalid doc id too long':
data['documentId'] = data.get('documentId') + '9'
data['documentId'] = data.get('documentId') + '999'
elif desc == 'Invalid attention too long':
data['attentionReference'] = LONG_ATTENTION_REF

Expand Down

0 comments on commit 45058d6

Please sign in to comment.