-
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 unit note, admin schema updates. (#51)
* MHR unit note, admin schema updates. Signed-off-by: Doug Lovett <[email protected]> * Update version. Signed-off-by: Doug Lovett <[email protected]> --------- Signed-off-by: Doug Lovett <[email protected]>
- Loading branch information
1 parent
65dec6c
commit a68c6fa
Showing
9 changed files
with
228 additions
and
2 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 |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Sample data used across many tests.""" | ||
# pylint: disable=too-many-lines | ||
|
||
ADDRESS = { | ||
'street': 'delivery_address - address line one', | ||
|
@@ -21,6 +22,33 @@ | |
'country': 'CA' | ||
} | ||
|
||
ADMIN_REGISTRATION = { | ||
'mhrNumber': '004816', | ||
'registrationType': 'REG_STAFF_ADMIN', | ||
'clientReferenceId': 'EX-NRED-001', | ||
'attentionReference': 'JOHN SMITH', | ||
'createDateTime': '2022-10-21T18:56:00+00:00', | ||
'submittingParty': { | ||
'businessName': 'BOB PATERSON HOMES INC.', | ||
'address': { | ||
'street': '1200 S. MACKENZIE AVE.', | ||
'city': 'WILLIAMS LAKE', | ||
'region': 'BC', | ||
'country': 'CA', | ||
'postalCode': 'V2G 3Y1' | ||
}, | ||
'phoneNumber': '6044620279', | ||
'emailAddress': '[email protected]' | ||
}, | ||
'documentType': 'NRED', | ||
'updateDocumentId': '62754188', | ||
'payment': { | ||
'receipt': '/pay/api/v1/payment-requests/2198744/receipts', | ||
'invoiceId': '2198744' | ||
} | ||
} | ||
|
||
|
||
BASE_INFORMATION = { | ||
'year': 2018, | ||
'make': 'WATSON IND. (ALTA)', | ||
|
@@ -583,7 +611,6 @@ | |
} | ||
} | ||
|
||
|
||
REGISTRATION_SUMMARY = [ | ||
{ | ||
'mhrNumber': '002000', | ||
|
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,54 @@ | ||
{ | ||
"definitions": {}, | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/adminRegistration", | ||
"type": "object", | ||
"title": "The MHR staff administration registration 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." | ||
}, | ||
"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"] | ||
}, | ||
"clientReferenceId": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 50, | ||
"description": "An optional client reference identifier associated with a change. Provided to facilitate client tracking of MHR activity." | ||
}, | ||
"attentionReference": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 50, | ||
"description": "The registration document attention or reference information." | ||
}, | ||
"submittingParty": { | ||
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/party" | ||
}, | ||
"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." | ||
}, | ||
"documentType": { | ||
"type": "string", | ||
"maxLength": 20, | ||
"enum": ["COU", "COUR", "EXRE", "FZE", "NREG", "THAW", "ABAN", "ATTA", "ADDI", "BANK", "COMP", "CONF", "DNCH", "FORE", "GENT", "MAID", "MAIL", "MARR", "MEAM", "NAMV", "PUBA", "REBU", "REIV", "REPV", "SZL", "TAXS", "VEST", "WHAL"] | ||
}, | ||
"updateDocumentId": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 8, | ||
"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." | ||
}, | ||
"payment": { | ||
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/common/paymentReference" | ||
} | ||
}, | ||
"required": [ | ||
"submittingParty", | ||
"documentType" | ||
] | ||
} |
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
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,71 @@ | ||
# 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 transport permit registration schema is valid.""" | ||
import copy | ||
|
||
import pytest | ||
|
||
from registry_schemas import validate | ||
from registry_schemas.example_data.mhr import ADMIN_REGISTRATION | ||
|
||
|
||
LONG_CLIENT_REF = '012345678901234567890123456789012345678901234567890' | ||
# testdata pattern is ({desc},{valid},{doc_type},{has_submitting},{is_request},{client_ref}, {attention}) | ||
TEST_DATA = [ | ||
('Valid request', True, 'COUR', 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), | ||
('Invalid missing doc type', False, None, True, True, None, None), | ||
('Invalid doc type', False, 'TAXN', True, True, None, None), | ||
('Invalid missing sub party', False, 'NRED', False, True, None, None), | ||
('Invalid update doc id', False, 'NRED', True, True, None, None) | ||
] | ||
|
||
|
||
@pytest.mark.parametrize('desc,valid,doc_type,has_sub,is_request,client_ref,attention', TEST_DATA) | ||
def test_note_registration(desc, valid, doc_type, has_sub, is_request, client_ref, attention): | ||
"""Assert that the staff admin registration schema is performing as expected.""" | ||
data = copy.deepcopy(ADMIN_REGISTRATION) | ||
if not doc_type: | ||
del data['documentType'] | ||
else: | ||
data['documentType'] = doc_type | ||
if not has_sub: | ||
del data['submittingParty'] | ||
if client_ref: | ||
data['clientReferenceId'] = client_ref | ||
else: | ||
del data['clientReferenceId'] | ||
if attention: | ||
data['attentionReference'] = attention | ||
else: | ||
del data['attentionReference'] | ||
if is_request: | ||
del data['mhrNumber'] | ||
del data['createDateTime'] | ||
del data['payment'] | ||
del data['registrationType'] | ||
if desc == 'Invalid update doc id': | ||
data['updateDocumentId'] = '123456789' | ||
is_valid, errors = validate(data, 'adminRegistration', 'mhr') | ||
|
||
if errors: | ||
for err in errors: | ||
print(err.message) | ||
|
||
if valid: | ||
assert is_valid | ||
else: | ||
assert not is_valid |
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