Skip to content

Commit

Permalink
MHR API correction/amendment registration schema updates. (#62)
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett authored Jan 15, 2024
1 parent 8b0b8cd commit d14cfc9
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 8 deletions.
17 changes: 15 additions & 2 deletions src/registry_schemas/schemas/mhr/adminRegistration.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"maxLength": 6,
"description": "Unique manufactured home registration number assigned by the Manufactured Home Registry when a registration is created."
},
"status": {
"type": [ "string", "null" ],
"maxLength": 20,
"enum": ["ACTIVE", "EXEMPT", "FROZEN", "CANCELLED"],
"description": "The status of the registration. ACTIVE - registered; FROZEN; EXEMPT;CANCELLED - cancelled. FROZEN is a temporary state where only BC Registries staff can make a change to the manufactured home."
},
"documentId": {
"type": [ "string", "null" ],
"maxLength": 8,
Expand Down Expand Up @@ -52,7 +58,7 @@
"documentType": {
"type": "string",
"maxLength": 20 ,
"enum": ["ADDI", "ATTA", "COMP", "CONF", "COUR", "DNCH", "EXRE", "FZE", "INTE", "INTW", "MAID", "MAIL", "MARR", "MEAM", "NAMV", "NCAN", "NRED", "PDEC", "PUBA", "REBU", "REGC", "STAT", "THAW", "WHAL", "AMEND_PERMIT", "CANCEL_PERMIT"]
"enum": ["ADDI", "ATTA", "COMP", "CONF", "COUR", "DNCH", "EXRE", "FZE", "INTE", "INTW", "MAID", "MAIL", "MARR", "MEAM", "NAMV", "NCAN", "NRED", "PDEC", "PUBA", "REBU", "REGC", "REGC_CLIENT", "REGC_STAFF", "STAT", "THAW", "WHAL", "AMEND_PERMIT", "CANCEL_PERMIT"]
},
"updateDocumentId": {
"type": [ "string", "null" ],
Expand All @@ -62,7 +68,14 @@
"note": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/note"
},
"ownerGroups": {
"deleteOwnerGroups": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/mhr/ownerGroup"
}
},
"addOwnerGroups": {
"type": "array",
"minItems": 1,
"items": {
Expand Down
5 changes: 5 additions & 0 deletions src/registry_schemas/schemas/mhr/registration.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"maxLength": 100,
"description": "Included in a response as a description of the registration report document."
},
"documentType": {
"type": "string",
"maxLength": 20,
"description": "Conditionally included in a response to support internal registration report generation."
},
"registrationType": {
"type": "string",
"maxLength": 20,
Expand Down
2 changes: 1 addition & 1 deletion src/registry_schemas/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '1.8.8' # pylint: disable=invalid-name
__version__ = '1.8.9' # pylint: disable=invalid-name
77 changes: 72 additions & 5 deletions tests/unit/mhr/test_admin_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
import pytest

from registry_schemas import validate
from registry_schemas.example_data.mhr import ADMIN_REGISTRATION, LOCATION
from registry_schemas.example_data.mhr import ADMIN_REGISTRATION, DESCRIPTION, LOCATION, OWNER_GROUP


LONG_CLIENT_REF = '012345678901234567890123456789012345678901234567890'
OWNER_GROUPS = [
OWNER_GROUP
]
# testdata pattern is ({desc},{valid},{doc_type},{has_submitting},{is_request},{client_ref}, {attention})
TEST_DATA = [
('Valid request COUR', True, 'COUR', True, True, None, None),
('Valid request NRED', True, 'NRED', True, True, None, None),
('Valid request NCAN', True, 'NCAN', True, True, None, None),
('Valid request REGC', True, 'REGC', True, True, None, None),
('Valid request STAT', True, 'STAT', True, True, None, None),
('Valid request CANCEL_PERMIT', True, 'CANCEL_PERMIT', True, True, None, None),
('Valid response CANCEL_PERMIT', True, 'CANCEL_PERMIT', True, True, None, None),
Expand All @@ -38,10 +40,28 @@
('Invalid missing sub party', False, 'NRED', False, True, None, None),
('Invalid update doc id', False, 'NRED', True, True, None, None)
]
# testdata pattern is ({desc},{valid},{doc_type},{status},{location},{description}, {owner_group})
TEST_DATA_AMEND_CORRECT = [
('Valid amendment location', True, 'PUBA', None, LOCATION, None, None),
('Valid staff correction location', True, 'REGC_STAFF', None, LOCATION, None, None),
('Valid client correction location', True, 'REGC_CLIENT', None, LOCATION, None, None),
('Valid amendment description', True, 'PUBA', None, None, DESCRIPTION, None),
('Valid staff correction description', True, 'REGC_STAFF', None, None, DESCRIPTION, None),
('Valid client correction description', True, 'REGC_CLIENT', None, None, DESCRIPTION, None),
('Valid amendment owners', True, 'PUBA', None, None, None, OWNER_GROUPS),
('Valid staff correction owners', True, 'REGC_STAFF', None, None, None, OWNER_GROUPS),
('Valid client correction owners', True, 'REGC_CLIENT', None, None, None, OWNER_GROUPS),
('Valid amendment status', True, 'PUBA', 'ACTIVE', None, None, None),
('Valid staff correction status', True, 'REGC_STAFF', 'EXEMPT', None, None, None),
('Invalid client correction status', False, 'REGC_CLIENT', 'JUNK', None, None, None),
('Invalid client correction location', False, 'REGC_CLIENT', None, LOCATION, None, None),
('Invalid staff correction description', False, 'REGC_STAFF', None, None, DESCRIPTION, None),
('Invalid amendment owners', False, 'PUBA', None, None, None, OWNER_GROUPS),
]


@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):
def test_admin_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:
Expand All @@ -65,8 +85,9 @@ def test_note_registration(desc, valid, doc_type, has_sub, is_request, client_re
del data['registrationType']
if desc == 'Invalid update doc id':
data['updateDocumentId'] = '123456789'
elif desc in ('Valid request REGC', 'Valid request STAT',
'Valid request CANCEL_PERMIT', 'Valid response CANCEL_PERMIT'):
elif desc in ('Valid request STAT',
'Valid request CANCEL_PERMIT',
'Valid response CANCEL_PERMIT'):
data['location'] = copy.deepcopy(LOCATION)
if desc in ('Valid request CANCEL_PERMIT', 'Valid response CANCEL_PERMIT'):
data['documentType'] = 'CANCEL_PERMIT'
Expand All @@ -81,3 +102,49 @@ def test_note_registration(desc, valid, doc_type, has_sub, is_request, client_re
assert is_valid
else:
assert not is_valid


@pytest.mark.parametrize('desc,valid,doc_type,status,location,description,owner_group', TEST_DATA_AMEND_CORRECT)
def test_admin_amend_correct(desc, valid, doc_type, status, location, description, owner_group):
"""Assert that the staff admin registration schema is performing as expected for amendments/corrections."""
data = copy.deepcopy(ADMIN_REGISTRATION)
data['documentType'] = doc_type
del data['mhrNumber']
del data['createDateTime']
del data['payment']
del data['registrationType']
if status:
data['status'] = status
if location:
if valid:
data['location'] = location
else:
bad_location = copy.deepcopy(location)
del bad_location['locationType']
data['location'] = bad_location
if description:
if valid:
data['description'] = description
else:
bad_desc = copy.deepcopy(description)
del bad_desc['sections']
data['description'] = bad_desc
if owner_group:
data['deleteOwnerGroups'] = owner_group
if valid:
data['addOwnerGroups'] = owner_group
else:
bad_owners = copy.deepcopy(owner_group)
del bad_owners[0]['type']
data['addOwnerGroups'] = bad_owners

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

0 comments on commit d14cfc9

Please sign in to comment.