Skip to content

Commit

Permalink
15050 consent continuation out (#126)
Browse files Browse the repository at this point in the history
* 15050 consent continuation out
* common schema for registrars order, registrars notation and consent continuation out
  • Loading branch information
vysakh-menon-aot authored Feb 9, 2023
1 parent f70aef8 commit 33d2c93
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/registry_schemas/example_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
CHANGE_OF_REGISTRATION_TEMPLATE,
COMMENT_BUSINESS,
COMMENT_FILING,
CONSENT_CONTINUATION_OUT,
CONTINUATION_IN,
CONTINUATION_IN_FILING_TEMPLATE,
CONVERSION_FILING_TEMPLATE,
Expand Down
6 changes: 6 additions & 0 deletions src/registry_schemas/example_data/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,11 @@
'fileKey': '011e332d-1b8e-4218-8710-ad8ac1fbc592.pdf'
}

CONSENT_CONTINUATION_OUT = {
'details': 'A note to explain the consent to continue out',
'courtOrder': COURT_ORDER
}

REGISTRARS_NOTATION = {
'fileNumber': '#1234-5678/90',
'orderDate': '2021-01-30T09:56:01+08:00',
Expand Down Expand Up @@ -2591,6 +2596,7 @@
('courtOrder', COURT_ORDER),
('registrarsNotation', REGISTRARS_NOTATION),
('registrarsOrder', REGISTRARS_ORDER),
('consentContinuationOut', CONSENT_CONTINUATION_OUT),
('registration', REGISTRATION),
('putBackOn', PUT_BACK_ON),
('adminFreeze', ADMIN_FREEZE)
Expand Down
29 changes: 29 additions & 0 deletions src/registry_schemas/schemas/consent_continuation_out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/consent_continuation_out",
"title": "Consent Continuation Out Schema",
"definitions": {},
"required": [
"consentContinuationOut"
],
"type": "object",
"properties": {
"consentContinuationOut": {
"type": "object",
"required": [
"details"
],
"properties": {
"details": {
"type": "string",
"minLength": 1,
"maxLength": 2000,
"description": "A brief note to explain the consent to continue out."
},
"courtOrder": {
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order#/properties/courtOrder"
}
}
}
}
}
20 changes: 12 additions & 8 deletions src/registry_schemas/schemas/filing.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"changeOfDirectors",
"changeOfName",
"changeOfRegistration",
"consentContinuationOut",
"continuationIn",
"continuedOut",
"conversion",
Expand Down Expand Up @@ -232,6 +233,9 @@
}
],
"anyOf": [
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/admin_freeze"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/alteration"
},
Expand All @@ -251,23 +255,29 @@
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/change_of_registration"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/conversion"
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/consent_continuation_out"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/continuation_in"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order"
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/conversion"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/correction"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/dissolution"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/incorporation_application"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/put_back_on"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/registrars_notation"
},
Expand All @@ -288,12 +298,6 @@
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/unmanaged"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/put_back_on"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/admin_freeze"
}
]
}
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 @@ -23,4 +23,4 @@
"""


__version__ = '2.17.0' # pylint: disable=invalid-name
__version__ = '2.18.0' # pylint: disable=invalid-name
1 change: 1 addition & 0 deletions tests/unit/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
('change_of_name.json'),
('change_of_registration.json'),
('comment.json'),
('consent_continuation_out.json'),
('contact_point.json'),
('continuation_in.json'),
('conversion.json'),
Expand Down
48 changes: 48 additions & 0 deletions tests/unit/test_consent_continuation_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright © 2023 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 consent continuation out schemas are valid."""

import copy

from registry_schemas import validate
from registry_schemas.example_data import CONSENT_CONTINUATION_OUT


def test_consent_continuation_out_schema():
"""Assert that the JSONSchema validator is working."""
legal_filing = {'consentContinuationOut': copy.deepcopy(CONSENT_CONTINUATION_OUT)}

is_valid, errors = validate(legal_filing, 'consent_continuation_out')

if errors:
for err in errors:
print(err.message)
print(errors)

assert is_valid


def test_consent_continuation_out_invalid_schema():
"""Assert that the JSONSchema validator is working."""
legal_filing = {'consentContinuationOut': copy.deepcopy(CONSENT_CONTINUATION_OUT)}
legal_filing['consentContinuationOut']['details'] = ''

is_valid, errors = validate(legal_filing, 'consent_continuation_out')

if errors:
for err in errors:
print(err.message)
print(errors)

assert not is_valid
50 changes: 27 additions & 23 deletions tests/unit/test_filings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
import copy
from datetime import datetime

import pytest

from registry_schemas import validate
from registry_schemas.example_data import (
ALTERATION_FILING_TEMPLATE,
ANNUAL_REPORT,
CHANGE_OF_ADDRESS,
CHANGE_OF_DIRECTORS,
CHANGE_OF_DIRECTORS_MAILING,
CONSENT_CONTINUATION_OUT,
CONVERSION_FILING_TEMPLATE,
COOPERATIVE,
CORP_CHANGE_OF_ADDRESS,
Expand Down Expand Up @@ -477,34 +480,35 @@ def test_registrars_order_filing_schema():
assert is_valid


def test_invalid_order_filing_schema_with_no_order():
@pytest.mark.parametrize('filing, filing_type, field_to_empty', [
(COURT_ORDER_FILING_TEMPLATE, 'courtOrder', 'fileNumber'),
(REGISTRARS_NOTATION_FILING_TEMPLATE, 'registrarsNotation', 'orderDetails'),
(REGISTRARS_ORDER_FILING_TEMPLATE, 'registrarsOrder', 'orderDetails'),
])
def test_invalid_order_filing_schema_with_no_order(filing, filing_type, field_to_empty):
"""Assert that the JSONSchema validator is working."""
court_order_json = copy.deepcopy(COURT_ORDER_FILING_TEMPLATE)
del court_order_json['filing']['courtOrder']
is_valid, errors = validate(court_order_json, 'filing')
filing_json = copy.deepcopy(filing)
del filing_json['filing'][filing_type]
is_valid, errors = validate(filing_json, 'filing')
assert not is_valid
print(errors)

court_order_json = copy.deepcopy(COURT_ORDER_FILING_TEMPLATE)
court_order_json['filing']['courtOrder']['fileNumber'] = ''
is_valid, errors = validate(court_order_json, 'filing')
filing_json = copy.deepcopy(filing)
filing_json['filing'][filing_type][field_to_empty] = ''
is_valid, errors = validate(filing_json, 'filing')
assert not is_valid
print(errors)

registrars_notation_json = copy.deepcopy(REGISTRARS_NOTATION_FILING_TEMPLATE)
del registrars_notation_json['filing']['registrarsNotation']
is_valid, errors = validate(registrars_notation_json, 'filing')
assert not is_valid

registrars_notation_json = copy.deepcopy(REGISTRARS_NOTATION_FILING_TEMPLATE)
registrars_notation_json['filing']['registrarsNotation']['orderDetails'] = ''
is_valid, errors = validate(registrars_notation_json, 'filing')
assert not is_valid
def test_consent_continuation_out_filing_schema():
"""Assert that the JSONSchema validator is working."""
filing = copy.deepcopy(FILING_HEADER)
filing['filing']['consentContinuationOut'] = copy.deepcopy(CONSENT_CONTINUATION_OUT)
is_valid, errors = validate(filing, 'filing')

registrars_order_json = copy.deepcopy(REGISTRARS_ORDER_FILING_TEMPLATE)
del registrars_order_json['filing']['registrarsOrder']
is_valid, errors = validate(registrars_order_json, 'filing')
assert not is_valid
if errors:
for err in errors:
print(err.message)
print(errors)

registrars_order_json = copy.deepcopy(REGISTRARS_ORDER_FILING_TEMPLATE)
registrars_order_json['filing']['registrarsOrder']['orderDetails'] = ''
is_valid, errors = validate(registrars_order_json, 'filing')
assert not is_valid
assert is_valid

0 comments on commit 33d2c93

Please sign in to comment.