Skip to content

Commit

Permalink
MHR api registration related schema updates. (#32)
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett authored Aug 9, 2022
1 parent cec2438 commit bf6b202
Show file tree
Hide file tree
Showing 14 changed files with 413 additions and 38 deletions.
2 changes: 2 additions & 0 deletions src/registry_schemas/example_data/mhr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
BASE_INFORMATION,
DESCRIPTION,
LOCATION,
MANUFACTURER_INFO,
NOTE,
OWNER,
OWNER_GROUP,
Expand All @@ -40,6 +41,7 @@
'BASE_INFORMATION',
'DESCRIPTION',
'LOCATION',
'MANUFACTURER_INFO',
'NOTE',
'OWNER',
'OWNER_GROUP',
Expand Down
63 changes: 55 additions & 8 deletions src/registry_schemas/example_data/mhr/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
'csaNumber': '786356',
'csaStandard': 'Z240',
'engineerDate': '2018-02-22T07:59:00+00:00',
'engineerName': ' Dave Smith ENG. LTD.'
'engineerName': ' Dave Smith ENG. LTD.',
'rebuiltRemarks': 'Rebuilt comments',
'otherRemarks': 'Other comments'
}

LOCATION = {
Expand All @@ -64,7 +66,49 @@
'pidNumber': '011625490',
'taxCertificate': True,
'taxExpiryDate': '2022-05-21T07:59:59+00:00',
'dealerName': 'NOR-TEC DESIGN GROUP LTD.'
'dealerName': 'NOR-TEC DESIGN GROUP LTD.',
'exceptionPlan': 'EXCEPT PART INCLUDED IN PLAN 7152',
'additionalDescription': 'SPALLUMCHEEN INDIAN RESERVE NO. 2',
'legalDescription': 'PARCEL C (O3806) OF LOT 10 DISTRICT LOT 9778 CARIBOO DISTRICT PLAN 2289',
'lot': '3',
'parcel': 'A (69860M)',
'block': '14',
'districtLot': '4913',
'partOf': 'NE 1/4',
'section': '34',
'township': '84',
'range': '35',
'meridian': 'W6M',
'landDistrict': 'CARIBOU',
'plan': '71177'
}

MANUFACTURER_INFO = {
'bcolAccountNumber': '378521',
'dealerName': 'CHAMPION CANADA INTERNATIONAL ULC - MODULINE INDUSTRIES',
'submittingParty': {
'businessName': 'CHAMPION CANADA INTERNATIONAL ULC',
'address': {
'street': 'PO BOX 190 STATION MAIN',
'city': 'PENTICTON',
'region': 'BC',
'postalCode': 'V2A 6J9',
'country': 'CA'
},
'phoneNumber': '2507701067'
},
'owner': {
'businessName': 'CHAMPION CANADA INTERNATIONAL ULC',
'address': {
'street': '3122B LYNNLARK PLACE',
'city': 'PENTICTON',
'region': 'BC',
'postalCode': 'V2A 5X5',
'country': 'CA'
},
'phoneNumber': '6044620279'
},
'manufacturerName': 'MODULINE INDUSTRIES - PENTICTON'
}

NOTE = {
Expand Down Expand Up @@ -94,7 +138,8 @@
},
'type': 'SO',
'phoneNumber': '6041234567',
'status': 'EXEMPT'
'status': 'EXEMPT',
'suffix': 'EXECUTOR OF THE WILL OF JUDITH ANN JANZEN, DECEASED'
}

OWNER_GROUP = {
Expand Down Expand Up @@ -135,7 +180,7 @@

REGISTRATION = {
'mhrNumber': '001234',
'status': 'R',
'status': 'ACTIVE',
'clientReferenceId': 'EX-MH001234',
'declaredValue': '120000.00',
'submittingParty': {
Expand Down Expand Up @@ -262,12 +307,14 @@
REGISTRATION_SUMMARY = [
{
'mhrNumber': '002000',
'statusType': 'R',
'registrationDescription': 'Manufactured Home Registration',
'username': 'Michael Scott',
'statusType': 'ACTIVE',
'clientReferenceId': 'T-0000001',
'path': '/mhr/api/v1/registrations/002000',
'createDateTime': '2021-06-03T22:58:45+00:00',
'registeringParty': 'Bank of British Columbia',
'securedParties': 'Bank of British Columbia',
'submittingParty': 'Bank of British Columbia',
'ownerNames': 'GRAEME THOMAS CUNNINGHAM, NEIL MARTIN FOLEY',
'inUserList': False
}
]
Expand Down Expand Up @@ -307,7 +354,7 @@
'details': [
{
'mhrNumber': '001234',
'status': 'R',
'status': 'ACTIVE',
'clientReferenceId': 'EX-MH001234',
'declaredValue': '120000.00',
'owners': [
Expand Down
10 changes: 10 additions & 0 deletions src/registry_schemas/schemas/mhr/description.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
"type": [ "string", "null" ],
"maxLength": 30,
"description": "The name of the engineer who performed the inspection."
},
"rebuiltRemarks": {
"type": [ "string", "null" ],
"maxLength": 280,
"description": "Comments on the rebuilt status of the home."
},
"otherRemarks": {
"type": [ "string", "null" ],
"maxLength": 140,
"description": "Other comments on the home."
}
},
"anyOf":[
Expand Down
70 changes: 70 additions & 0 deletions src/registry_schemas/schemas/mhr/location.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,80 @@
"format": "date-time",
"description": "The tax certificate expiry date as date-time. Omit if no value provided."
},
"exceptionPlan": {
"type": [ "string", "null" ],
"maxLength": 80,
"description": "Exception plan number or description."
},
"dealerName": {
"type": [ "string", "null" ],
"maxLength": 60,
"description": "The name of the manufacured home dealer."
},
"additionalDescription": {
"type": [ "string", "null" ],
"maxLength": 80,
"description": "Additional location information."
},
"legalDescription": {
"type": [ "string", "null" ],
"maxLength": 512,
"description": "LTSA parcel identifier legal description. May be submitted with new registrations requests. In the future it may be included in search results."
},
"lot": {
"type": [ "string", "null" ],
"maxLength": 10,
"description": "LTSA lot number."
},
"parcel": {
"type": [ "string", "null" ],
"maxLength": 10,
"description": "LTSA parcel description."
},
"block": {
"type": [ "string", "null" ],
"maxLength": 10,
"description": "LTSA block number."
},
"districtLot": {
"type": [ "string", "null" ],
"maxLength": 17,
"description": "LTSA district lot number."
},
"partOf": {
"type": [ "string", "null" ],
"maxLength": 10,
"description": "Part of abbreviated description derived from the LTSA legal description."
},
"section": {
"type": [ "string", "null" ],
"maxLength": 10,
"description": "LTSA section number."
},
"township": {
"type": [ "string", "null" ],
"maxLength": 2,
"description": "LTSA township number."
},
"range": {
"type": [ "string", "null" ],
"maxLength": 2,
"description": "LTSA range number."
},
"meridian": {
"type": [ "string", "null" ],
"maxLength": 3,
"description": "Abbreviated meridian description derived from the LTSA legal description of the meridian."
},
"landDistrict": {
"type": [ "string", "null" ],
"maxLength": 20,
"description": "LTSA district description."
},
"plan": {
"type": [ "string", "null" ],
"maxLength": 12,
"description": "LTSA plan number."
}
},
"required": [
Expand Down
35 changes: 35 additions & 0 deletions src/registry_schemas/schemas/mhr/manufacturerInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/manufacturerInfo",
"type": "object",
"title": "The MHR Manufacturer Information Schema",
"definitions": {},
"properties": {
"bcolAccountNumber": {
"type": "string",
"maxLength": 6,
"description": "The legacy BC Online Account number for the manufacturer."
},
"dealerName": {
"type": "string",
"maxLength": 60,
"description": "The name of the manufacturer dealer."
},
"submittingParty": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/party"
},
"owner": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/party"
},
"manufacturerName": {
"type": "string",
"maxLength": 65,
"description": "The name of the manufacturer."
}
},
"required": [
"dealerName",
"submittingParty",
"manufacturerName"
]
}
5 changes: 5 additions & 0 deletions src/registry_schemas/schemas/mhr/owner.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
"type": "string",
"maxLength": 20,
"description": "The owner phone number formatted as only digits: no spaces, periods, or dashes."
},
"suffix": {
"type": "string",
"maxLength": 70,
"description": "The organization or individual name suffix."
}
},
"oneOf":[
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 @@ -12,9 +12,9 @@
},
"status": {
"type": [ "string", "null" ],
"maxLength": 2,
"enum": ["C", "D", "E", "R"],
"description": "The status of the registration. C - cancelled; D - drafted; E - exempted; R - registered."
"maxLength": 20,
"enum": ["ACTIVE", "DRAFT", "EXEMPT", "HISTORICAL"],
"description": "The status of the registration. ACTIVE - registered; DRAFT; EXEMPT; HISTORICAL - cancelled."
},
"clientReferenceId": {
"type": [ "string", "null" ],
Expand Down
25 changes: 20 additions & 5 deletions src/registry_schemas/schemas/mhr/registrationSummary.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@
"maxLength": 6,
"description": "The MHR Number that uniquely identifies the registration."
},
"registrationDescription": {
"type": "string",
"maxLength": 100,
"description": "Description of the registration type."
},
"username": {
"type": "string",
"maxLength": 250,
"description": "Name of the user who created the registration. Empty string for legacy registrations."
},
"statusType": {
"type": "string",
"maxLength": 3,
"enum": ["R", "C", "D", "E"],
"description": "The status of the Registration. One of <ul><li>R - Registered</li><li>C - Cancelled</li><li>D - Drafted</li><li>E - Exempted</li></ul>"
"maxLength": 20,
"enum": ["ACTIVE", "DRAFT", "EXEMPT", "HISTORICAL"],
"description": "The status of the registration. ACTIVE - registered; DRAFT; EXEMPT; HISTORICAL - cancelled."
},
"path": {
"type": "string",
Expand All @@ -31,10 +41,15 @@
"maxLength": 50,
"description": "An optional client reference identifier associated with the registration. Provided to facilitate client tracking of MHR activity."
},
"registeringParty": {
"submittingParty": {
"type": "string",
"maxlength": 150,
"description": "The registration Registering Party name."
"description": "The registration Submitting Party name."
},
"ownerNames": {
"type": "string",
"maxlength": 1000,
"description": "The names of one or more of the registration active owners, separated by a comma in the format first middle last."
},
"inUserList": {
"type": "boolean",
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/mhr/test_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
# testdata pattern is ({desc}, {valid}, {manu}, {base}, {sc}, {has_s}, {csa_n}, {csa_s}, {eng_date}, {eng_name})
LONG_MANUFACTURER = '012345678901234567890123456789012345678901234567890123456789012345'
LONG_ENG_NAME = '0123456789012345678901234567890'
LONG_REMARK = '0123456789012345678901234567890123456789012345678901234567890123456789'
REBUILT_MAX_LENGTH = LONG_REMARK + LONG_REMARK + LONG_REMARK + LONG_REMARK
OTHER_MAX_LENGTH = LONG_REMARK + LONG_REMARK
TEST_DATA_DESC = [
('Valid all', True, 'manufacturer', True, 1, True, 'csa num', 'csas', True, 'eng name'),
('Valid no csa', True, 'manufacturer', True, 1, True, None, None, True, 'eng name'),
Expand All @@ -37,6 +40,12 @@
('Invalid csa standard too long', False, 'manufacturer', True, 1, True, '0123456789', '12345', True, 'eng name'),
('Invalid eng name too long', False, 'manufacturer', True, 1, True, '012345678', 'csas', True, LONG_ENG_NAME)
]
# testdata pattern is ({desc}, {valid}, {rebuilt}, {other})
TEST_REMARKS_DATA_DESC = [
('Valid Max Both', True, REBUILT_MAX_LENGTH, OTHER_MAX_LENGTH),
('Invalid rebuilt too long', False, REBUILT_MAX_LENGTH + 'X', OTHER_MAX_LENGTH),
('Invalid other too long', False, REBUILT_MAX_LENGTH, OTHER_MAX_LENGTH + 'X')
]


@pytest.mark.parametrize('desc,valid,manu,base,sc,has_s,csa_n,csa_s,eng_date,eng_name', TEST_DATA_DESC)
Expand Down Expand Up @@ -75,3 +84,21 @@ def test_description(desc, valid, manu, base, sc, has_s, csa_n, csa_s, eng_date,
assert is_valid
else:
assert not is_valid


@pytest.mark.parametrize('desc,valid,rebuilt,other', TEST_REMARKS_DATA_DESC)
def test_description_remarks(desc, valid, rebuilt, other):
"""Assert that the schema remarks validation is performing as expected."""
data = copy.deepcopy(DESCRIPTION)
data['rebuiltRemarks'] = rebuilt
data['otherRemarks'] = other
is_valid, errors = validate(data, 'description', 'mhr')

if errors:
for err in errors:
print(err.message)

if valid:
assert is_valid
else:
assert not is_valid
Loading

0 comments on commit bf6b202

Please sign in to comment.