-
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 changes to support drafts. (#35)
* MHR api changes to support drafts. Signed-off-by: Doug Lovett <[email protected]> * Rename draftId to draftNumber. Signed-off-by: Doug Lovett <[email protected]> * Rename draftId to draftNumber. Signed-off-by: Doug Lovett <[email protected]> * Add submittingParty to draftSummary. Signed-off-by: Doug Lovett <[email protected]> Signed-off-by: Doug Lovett <[email protected]>
- Loading branch information
1 parent
e849a36
commit e75bb0c
Showing
9 changed files
with
349 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -52,6 +52,103 @@ | |
'otherRemarks': 'Other comments' | ||
} | ||
|
||
DRAFT_SUMMARY = [ | ||
{ | ||
'draftNumber': '150234', | ||
'registrationType': 'MHREG', | ||
'registrationDescription': 'REGISTER NEW UNIT', | ||
'path': '/mhr/api/v1/drafts/00000234', | ||
'createDateTime': '2020-02-21T18:56:20+00:00', | ||
'lastUpdateDateTime': '2022-02-21T18:56:20+00:00', | ||
'registeringName': 'Michael Smith', | ||
'clientReferenceId': 'D-100001020', | ||
'submittingParty': 'JOHN SMITH NOTARY PUBLIC' | ||
}, | ||
{ | ||
'draftNumber': '150234', | ||
'mhrNumber': '125234', | ||
'registrationType': 'TRANS', | ||
'registrationDescription': 'SALE OR GIFT', | ||
'path': '/mhr/api/v1/drafts/00000191', | ||
'createDateTime': '2022-11-23T22:58:46+00:00', | ||
'lastUpdateDateTime': '2022-11-30T18:22:22+00:00', | ||
'registeringName': 'Michael Smith', | ||
'clientReferenceId': 'D-100001005', | ||
'submittingParty': 'JOHN SMITH NOTARY PUBLIC' | ||
} | ||
] | ||
|
||
DRAFT_TRANSFER = { | ||
'draftNumber': '150234', | ||
'type': 'TRANS', | ||
'registration': { | ||
'draftNumber': '150234', | ||
'mhrNumber': '125234', | ||
'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' | ||
} | ||
], | ||
'deathOfOwner': False | ||
}, | ||
'createDateTime': '2020-02-21T18:56:20+00:00', | ||
'lastUpdateDateTime': '2020-02-21T18:56:20+00:00' | ||
} | ||
|
||
LOCATION = { | ||
'locationType': 'MH_PARK', | ||
'status': 'ACTIVE', | ||
|
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,37 @@ | ||
{ | ||
"definitions": {}, | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/draft", | ||
"type": "object", | ||
"title": "The MHR Draft Schema", | ||
"properties": { | ||
"draftNumber": { | ||
"type": "string", | ||
"maxLength": 10, | ||
"description": "The identifier of the draft document. It is generated and returned in the response when the draft is first created." | ||
}, | ||
"type": { | ||
"type": "string", | ||
"maxLength": 20, | ||
"enum": ["EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "PERMIT", "TRANS", "TRAND"], | ||
"description": "<p>The set of registration types supported by this API.<ol><li>EXEMPTION_NON_RES - non-residential exemption</li><li>EXEMPTION_RES - residential exemption</li><li>MHREG - manufactured home registration</li><li>PERMIT - transport permit</li><li>TRAND - transfer due to the death of a joint tenant</li><li>TRANS - transfer sale or gift</li></ol></p>" | ||
}, | ||
"registration": { | ||
"type": "object" | ||
}, | ||
"createDateTime": { | ||
"type": [ "string", "null" ], | ||
"format": "date-time", | ||
"description": "Generated by the MHR application and included in a response, the date and time a record is created in the system." | ||
}, | ||
"lastUpdateDateTime": { | ||
"type": [ "string", "null" ], | ||
"format": "date-time", | ||
"description": "Generated by the MHR application and included in a response, the date and time of the last change to the draft. Null if no update is made." | ||
} | ||
}, | ||
"required": [ | ||
"type", | ||
"registration" | ||
] | ||
} |
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,74 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/draftSummary", | ||
"type": "array", | ||
"title": "The MHR Draft Summary List Schema", | ||
"definitions": { | ||
"draftSummary": { | ||
"type": "object", | ||
"properties": { | ||
"draftNumber": { | ||
"type": "string", | ||
"maxLength": 10, | ||
"description": "The identifier of the draft document. It is generated and returned in the response when the draft is first created." | ||
}, | ||
"mhrNumber": { | ||
"type": [ "string", "null" ], | ||
"minLength": 6, | ||
"maxLength": 6, | ||
"description": "For changes registrations, the MH Registration Number for the manufactured home that the change applies to. It is empty for a draft MH registrations." | ||
}, | ||
"registrationType": { | ||
"type": "string", | ||
"maxLength": 20, | ||
"enum": ["EXEMPTION_RES", "EXEMPTION_NON_RES", "MHREG", "PERMIT", "TRANS", "TRAND"], | ||
"description": "<p>The set of registration types supported by this API.<ol><li>EXEMPTION_NON_RES - non-residential exemption</li><li>EXEMPTION_RES - residential exemption</li><li>MHREG - manufactured home registration</li><li>PERMIT - transport permit</li><li>TRAND - transfer due to the death of a joint tenant</li><li>TRANS - transfer sale or gift</li></ol></p>" | ||
}, | ||
"registrationDescription": { | ||
"type": "string", | ||
"maxLength": 100, | ||
"description": "A description of the registration type, generated by the MHR application and returned in the response." | ||
}, | ||
"path": { | ||
"type": "string", | ||
"maxLength": 250, | ||
"description": "The relative path for a GET request to retrieve an individual draft document." | ||
}, | ||
"registeringName": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 150, | ||
"description": "The name of the person who submitted the draft request in the format first name last name." | ||
}, | ||
"createDateTime": { | ||
"type": [ "string", "null" ], | ||
"format": "date-time", | ||
"description": "Generated by the MHR application, the date and time the draft is created." | ||
}, | ||
"lastUpdateDateTime": { | ||
"type": [ "string", "null" ], | ||
"format": "date-time", | ||
"description": "Generated by the MHR application, the date and time the of the most recent draft update. When the draft is created it is identical to createDateTime." | ||
}, | ||
"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": { | ||
"type": "string", | ||
"maxlength": 150, | ||
"description": "The registration Submitting Party name." | ||
} | ||
}, | ||
"required": [ | ||
"draftNumber", | ||
"registrationType", | ||
"path", | ||
"createDateTime" | ||
] | ||
} | ||
}, | ||
"items": { | ||
"$ref": "#/definitions/draftSummary" | ||
} | ||
} |
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,67 @@ | ||
# 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 MHGR Draft schema is valid.""" | ||
import copy | ||
|
||
import pytest | ||
|
||
from registry_schemas import validate | ||
from registry_schemas.example_data.mhr import DRAFT_TRANSFER | ||
|
||
|
||
# testdata pattern is ({desc}, {valid}, {type}, {has_reg}, {create}, {update}, {draft_id}) | ||
TEST_DATA_TRANSFER = [ | ||
('Valid TRANS', True, 'TRANS', True, None, None, None), | ||
('Valid TRAND', True, 'TRAND', True, None, None, None), | ||
('Valid MHREG', True, 'MHREG', True, None, None, None), | ||
('Valid PERMIT', True, 'PERMIT', True, None, None, None), | ||
('Valid EXEMPTION_RES', True, 'EXEMPTION_RES', True, None, None, None), | ||
('Valid EXEMPTION_NON_RES', True, 'EXEMPTION_NON_RES', True, None, None, None), | ||
('Invalid missing type', False, None, True, None, None, None), | ||
('Invalid type', False, 'XXXXX', True, None, None, None), | ||
('Invalid missing registration', False, 'TRANS', False, None, None, None), | ||
('Invalid create', False, 'TRANS', True, 'XXXXXXXXXXXX', None, None), | ||
('Invalid update', False, 'TRANS', True, None, 'XXXXXXXXXXXX', None), | ||
('Invalid draft id too long', False, 'TRANS', True, None, None, '01234567891') | ||
] | ||
|
||
|
||
@pytest.mark.parametrize('desc,valid,type,has_reg,create,update,draft_id', TEST_DATA_TRANSFER) | ||
def test_draft(desc, valid, type, has_reg, create, update, draft_id): | ||
"""Assert that the schema is performing as expected for a draft.""" | ||
draft = copy.deepcopy(DRAFT_TRANSFER) | ||
if not type: | ||
del draft['type'] | ||
else: | ||
draft['type'] = type | ||
if not has_reg: | ||
del draft['registration'] | ||
if create: | ||
draft['createDateTime'] = create | ||
if update: | ||
draft['lastUpdateDateTime'] = update | ||
if draft_id: | ||
draft['draftNumber'] = draft_id | ||
|
||
is_valid, errors = validate(draft, 'draft', 'mhr') | ||
|
||
if errors: | ||
for err in errors: | ||
print(err.message) | ||
print(errors) | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# 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 PPR Draft Summary schema is valid.""" | ||
import copy | ||
|
||
import pytest | ||
|
||
from registry_schemas import validate | ||
from registry_schemas.example_data.mhr import DRAFT_SUMMARY | ||
|
||
|
||
# testdata pattern is ({desc}, {valid}, {empty}, {has_id}, {has_type}, {has_path}, {has_create}) | ||
TEST_DATA = [ | ||
('Valid non-empty', True, False, True, True, True, True), | ||
('Valid empty', True, True, True, True, True, True), | ||
('Invalid missing draftNumber', False, False, False, True, True, True), | ||
('Invalid missing type', False, False, True, False, True, True), | ||
('Invalid missing path', False, False, True, True, False, True), | ||
('Invalid missing createDateTime', False, False, True, True, True, False) | ||
] | ||
|
||
|
||
@pytest.mark.parametrize('desc,valid,empty,has_id,has_type,has_path,has_create', TEST_DATA) | ||
def test_draft_summary(desc, valid, empty, has_id, has_type, has_path, has_create): | ||
"""Assert that the schema is performing as expected for a draft summary list.""" | ||
drafts = copy.deepcopy(DRAFT_SUMMARY) | ||
if empty: | ||
drafts = [] | ||
else: | ||
if not has_id: | ||
del drafts[0]['draftNumber'] | ||
if not has_type: | ||
del drafts[0]['registrationType'] | ||
if not has_path: | ||
del drafts[0]['path'] | ||
if not has_create: | ||
del drafts[0]['createDateTime'] | ||
is_valid, errors = validate(drafts, 'draftSummary', 'mhr') | ||
|
||
if errors: | ||
for err in errors: | ||
print(err.message) | ||
print(errors) | ||
|
||
if valid: | ||
assert is_valid | ||
else: | ||
assert not is_valid |