-
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.
Schema changes to support MHR create registrations. (#27)
Signed-off-by: Doug Lovett <[email protected]>
- Loading branch information
1 parent
3e51d5d
commit bd0ef33
Showing
12 changed files
with
322 additions
and
13 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
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,50 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/registrationSummary", | ||
"type": "object", | ||
"title": "The MHR Registration Summary Schema", | ||
"definitions": {}, | ||
"properties": { | ||
"mhrNumber": { | ||
"type": "string", | ||
"maxLength": 6, | ||
"description": "The MHR Number that uniquely identifies the registration." | ||
}, | ||
"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>" | ||
}, | ||
"path": { | ||
"type": "string", | ||
"maxLength": 150, | ||
"description": "The relative path for a GET request to retrieve an individual registration." | ||
}, | ||
"createDateTime": { | ||
"type": "string", | ||
"format": "date-time", | ||
"description": "Generated by the system, the date and time the registration is created." | ||
}, | ||
"clientReferenceId": { | ||
"type": [ "string", "null" ], | ||
"maxLength": 50, | ||
"description": "An optional client reference identifier associated with the registration. Provided to facilitate client tracking of MHR activity." | ||
}, | ||
"registeringParty": { | ||
"type": "string", | ||
"maxlength": 150, | ||
"description": "The registration Registering Party name." | ||
}, | ||
"inUserList": { | ||
"type": "boolean", | ||
"description": "True if the base registration is already included in the account registrations list." | ||
} | ||
}, | ||
"required": [ | ||
"mhrNumber", | ||
"statusType", | ||
"createDateTime", | ||
"path" | ||
] | ||
} |
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 |
---|---|---|
|
@@ -20,8 +20,50 @@ | |
from registry_schemas.example_data.mhr import REGISTRATION | ||
|
||
|
||
# testdata pattern is ({desc},{valid},{mhr},{status},{rev},{decv},{haso},{hasl},{hasd},{hasn},{hasdt},{hasp}) | ||
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]', | ||
'birthDate': '1986-12-01T19:20:20-08:00', | ||
'phoneNumber': '6042314598' | ||
} | ||
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]', | ||
'birthDate': '1986-12-01T19:20:20-08:00', | ||
'phoneNumber': '2314598' | ||
} | ||
PPR_REG_VALID = [ | ||
{ | ||
'reg_data': 'any data allowed' | ||
} | ||
] | ||
PPR_REG_EMPTY = [] | ||
|
||
LONG_CLIENT_REF = '01234567890123456789012345678901234567890' | ||
|
||
# testdata pattern is ({desc},{valid},{mhr},{status},{rev},{decv},{haso},{hasl},{hasd},{hasn},{hasdt},{hasp}) | ||
TEST_DATA_REG = [ | ||
('Valid request', True, None, None, 'ref', '50000.00', True, True, True, True, False, False), | ||
('Valid response', True, '003456', 'R', 'ref', '50000.00', True, True, True, True, True, True), | ||
|
@@ -37,6 +79,20 @@ | |
('Invalid declared val too long', False, None, None, 'ref', '1234567890.00', True, True, True, True, False, False) | ||
] | ||
|
||
# testdata pattern is ({desc},{valid},{reg_party}) | ||
TEST_DATA_REG_PARTY = [ | ||
('Valid request with party', True, PARTY_VALID), | ||
('Invalid request invalid party', False, PARTY_INVALID), | ||
('Valid request no party', True, None) | ||
] | ||
|
||
# testdata pattern is ({desc},{valid},{ppr_registrations}) | ||
TEST_DATA_PPR_REGISTRATIONS = [ | ||
('Valid request with ppr registrations', True, PPR_REG_VALID), | ||
('Valid request empty ppr registrations', True, PPR_REG_EMPTY), | ||
('Valid request no ppr registrations', True, None) | ||
] | ||
|
||
|
||
@pytest.mark.parametrize('desc,valid,mhr,status,ref,decv,haso,hasl,hasd,hasn,hasdt,hasp', TEST_DATA_REG) | ||
def test_registration(desc, valid, mhr, status, ref, decv, haso, hasl, hasd, hasn, hasdt, hasp): | ||
|
@@ -81,3 +137,41 @@ def test_registration(desc, valid, mhr, status, ref, decv, haso, hasl, hasd, has | |
assert is_valid | ||
else: | ||
assert not is_valid | ||
|
||
|
||
@pytest.mark.parametrize('desc,valid,reg_party', TEST_DATA_REG_PARTY) | ||
def test_registration_reg_party(desc, valid, reg_party): | ||
"""Assert that the schema is performing as expected with a registering party.""" | ||
data = copy.deepcopy(REGISTRATION) | ||
if reg_party: | ||
data['registeringParty'] = reg_party | ||
|
||
is_valid, errors = validate(data, 'registration', '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,ppr_registrations', TEST_DATA_PPR_REGISTRATIONS) | ||
def test_registration_ppr_registrations(desc, valid, ppr_registrations): | ||
"""Assert that the schema is performing as expected with a registering party.""" | ||
data = copy.deepcopy(REGISTRATION) | ||
if ppr_registrations: | ||
data['pprRegistrations'] = ppr_registrations | ||
|
||
is_valid, errors = validate(data, 'registration', 'mhr') | ||
|
||
if errors: | ||
for err in errors: | ||
print(err.message) | ||
|
||
if valid: | ||
assert is_valid | ||
else: | ||
assert not is_valid |
Oops, something went wrong.