-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MHR api transfer and location schema updates. (#34)
Signed-off-by: Doug Lovett <[email protected]> Signed-off-by: Doug Lovett <[email protected]>
- Loading branch information
1 parent
de6841b
commit e849a36
Showing
8 changed files
with
297 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,8 @@ | |
} | ||
|
||
LOCATION = { | ||
'locationType': 'MH_PARK', | ||
'status': 'ACTIVE', | ||
'parkName': 'HIDDEN VALLEY TRAILER COURT', | ||
'pad': '20', | ||
'address': { | ||
|
@@ -181,6 +183,7 @@ | |
REGISTRATION = { | ||
'mhrNumber': '001234', | ||
'documentId': '42800656', | ||
'documentDescription': 'REGISTER NEW UNIT', | ||
'status': 'ACTIVE', | ||
'clientReferenceId': 'EX-MH001234', | ||
'declaredValue': '120000.00', | ||
|
@@ -248,6 +251,8 @@ | |
} | ||
], | ||
'location': { | ||
'locationType': 'OTHER', | ||
'status': 'ACTIVE', | ||
'parkName': 'HIDDEN VALLEY TRAILER COURT', | ||
'pad': '20', | ||
'address': { | ||
|
@@ -410,6 +415,7 @@ | |
} | ||
], | ||
'location': { | ||
'locationType': 'OTHER', | ||
'parkName': 'HIDDEN VALLEY TRAILER COURT', | ||
'pad': '20', | ||
'address': { | ||
|
@@ -537,3 +543,74 @@ | |
'widthFeet': 12, | ||
'widthInches': 0 | ||
} | ||
|
||
TRANSFER = { | ||
'mhrNumber': '125234', | ||
'documentId': '10104535', | ||
'documentDescription': 'SALE OR GIFT', | ||
'clientReferenceId': 'EX-TRANS-001', | ||
'submittingParty': { | ||
'businessName': 'ABC SEARCHING COMPANY', | ||
'address': { | ||
'street': '222 SUMMER STREET', | ||
'city': 'VICTORIA', | ||
'region': 'BC', | ||
'country': 'CA', | ||
'postalCode': 'V8W 2V8' | ||
}, | ||
'emailAddress': '[email protected]', | ||
'phoneNumber': '6041234567', | ||
'phoneExtension': '546' | ||
}, | ||
'deleteOwnerGroups': [ | ||
{ | ||
'groupId': 1, | ||
'owners': [ | ||
{ | ||
'individualName': { | ||
'first': 'Jane', | ||
'last': 'Smith' | ||
}, | ||
'address': { | ||
'street': '3122B LYNNLARK PLACE', | ||
'city': 'VICTORIA', | ||
'region': 'BC', | ||
'postalCode': ' ', | ||
'country': 'CA' | ||
}, | ||
'phoneNumber': '6041234567' | ||
} | ||
], | ||
'type': 'SOLE' | ||
} | ||
], | ||
'addOwnerGroups': [ | ||
{ | ||
'groupId': 2, | ||
'owners': [ | ||
{ | ||
'individualName': { | ||
'first': 'James', | ||
'last': 'Smith' | ||
}, | ||
'address': { | ||
'street': '3122B LYNNLARK PLACE', | ||
'city': 'VICTORIA', | ||
'region': 'BC', | ||
'postalCode': ' ', | ||
'country': 'CA' | ||
}, | ||
'phoneNumber': '6041234567' | ||
} | ||
], | ||
'type': 'SOLE', | ||
'status': 'ACTIVE' | ||
} | ||
], | ||
'createDateTime': '2020-02-21T18:56:20+00:00', | ||
'deathOfOwner': False, | ||
'payment': { | ||
'receipt': '/pay/api/v1/payment-requests/2199900/receipts', | ||
'invoiceId': '2199900' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"definitions": {}, | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/transfer", | ||
"type": "object", | ||
"title": "The MHR Manufactured Home Transfer of Sale/Owner Schema", | ||
"properties": { | ||
"mhrNumber": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 6, | ||
"description": "Unique manufactured home registration number assigned by the Manufactured Home Registry when a registration is created." | ||
}, | ||
"documentId": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 8, | ||
"minLength": 8, | ||
"description": "Unique registration document ID/number assigned by the Manufactured Home Registry." | ||
}, | ||
"documentDescription": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 100, | ||
"description": "Included in a response as a description of the registration report document." | ||
}, | ||
"clientReferenceId": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 40, | ||
"description": "An optional client reference identifier associated with a change. Provided to facilitate client tracking of MHR activity." | ||
}, | ||
"submittingParty": { | ||
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/party" | ||
}, | ||
"deleteOwnerGroups": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/ownerGroup" | ||
} | ||
}, | ||
"addOwnerGroups": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/ownerGroup" | ||
} | ||
}, | ||
"createDateTime": { | ||
"type": [ "string", "null" ], | ||
"format": "date-time", | ||
"description": "Generated by the MHR system and included in a response, the date and time a record is created in the system in the ISO 8601 format YYYY-MM-DDThh:mm:ssTZD." | ||
}, | ||
"deathOfOwner": { | ||
"type": "boolean", | ||
"description": "Set to true when transferfing fractional interest in a home because a partner in a joint tenancy has died." | ||
}, | ||
"payment": { | ||
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/paymentReference" | ||
} | ||
}, | ||
"required": [ | ||
"submittingParty", | ||
"deleteOwnerGroups", | ||
"addOwnerGroups" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Copyright © 2020 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Test Suite to ensure the MHR transfer (tranfer of sale) schema is valid.""" | ||
import copy | ||
|
||
import pytest | ||
|
||
from registry_schemas import validate | ||
from registry_schemas.example_data.mhr import TRANSFER | ||
|
||
|
||
PARTY_VALID = { | ||
'personName': { | ||
'first': 'Michael', | ||
'middle': 'J', | ||
'last': 'Smith' | ||
}, | ||
'address': { | ||
'street': '520 Johnson St', | ||
'city': 'Victoria', | ||
'region': 'BC', | ||
'country': 'CA', | ||
'postalCode': 'V8S 2V4' | ||
}, | ||
'emailAddress': '[email protected]', | ||
'phoneNumber': '6042314598', | ||
'phoneExtension': '546' | ||
} | ||
PARTY_INVALID = { | ||
'personName': { | ||
'first': 'Michael', | ||
'middle': 'J', | ||
'last': 'Smith' | ||
}, | ||
'address': { | ||
'street': '520 Johnson St', | ||
'city': 'Victoria', | ||
'region': 'BC', | ||
'country': 'CA', | ||
'postalCode': 'V8S 2V4' | ||
}, | ||
'emailAddress': '[email protected]', | ||
'phoneNumber': '2314598' | ||
} | ||
LONG_CLIENT_REF = '01234567890123456789012345678901234567890' | ||
|
||
# testdata pattern is ({desc},{valid},{sub_party},{add},{delete},{is_request},{client_ref}) | ||
TEST_DATA = [ | ||
('Valid request', True, PARTY_VALID, True, True, True, None), | ||
('Valid response', True, PARTY_VALID, True, True, False, '1234'), | ||
('Invalid client ref', False, PARTY_VALID, True, True, True, LONG_CLIENT_REF), | ||
('Invalid sub party', False, PARTY_INVALID, True, True, True, '1234'), | ||
('Missing sub party', False, None, True, True, True, '1234'), | ||
('Invalid missing add', False, PARTY_VALID, False, True, True, '1234'), | ||
('Invalid missing delete', False, PARTY_VALID, True, False, True, ''), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize('desc,valid,sub_party,add,delete,is_request,client_ref', TEST_DATA) | ||
def test_transfer(desc, valid, sub_party, add, delete, is_request, client_ref): | ||
"""Assert that the schema is performing as expected.""" | ||
data = copy.deepcopy(TRANSFER) | ||
if sub_party: | ||
data['submittingParty'] = sub_party | ||
else: | ||
del data['submittingParty'] | ||
if client_ref: | ||
data['clientReferenceId'] = client_ref | ||
else: | ||
del data['clientReferenceId'] | ||
if is_request: | ||
del data['createDateTime'] | ||
del data['payment'] | ||
del data['mhrNumber'] | ||
del data['documentId'] | ||
del data['documentDescription'] | ||
if not add: | ||
del data['addOwnerGroups'] | ||
if not delete: | ||
del data['deleteOwnerGroups'] | ||
|
||
is_valid, errors = validate(data, 'transfer', 'mhr') | ||
|
||
if errors: | ||
for err in errors: | ||
print(err.message) | ||
|
||
if valid: | ||
assert is_valid | ||
else: | ||
assert not is_valid |