diff --git a/src/registry_schemas/example_data/__init__.py b/src/registry_schemas/example_data/__init__.py index 19ac28e..a519dfd 100644 --- a/src/registry_schemas/example_data/__init__.py +++ b/src/registry_schemas/example_data/__init__.py @@ -37,11 +37,16 @@ CORRECTION_COMBINED_AR, CORRECTION_INCORPORATION, COURT_ORDER, + COURT_ORDER_FILING_TEMPLATE, FILING_HEADER, FILING_TEMPLATE, FILINGS_WITH_TYPES, INCORPORATION, INCORPORATION_FILING_TEMPLATE, + REGISTRARS_NOTATION, + REGISTRARS_NOTATION_FILING_TEMPLATE, + REGISTRARS_ORDER, + REGISTRARS_ORDER_FILING_TEMPLATE, SPECIAL_RESOLUTION, STUB_FILING, TRANSITION, @@ -66,11 +71,16 @@ 'CORRECTION_COMBINED_AR', 'CORRECTION_INCORPORATION', 'COURT_ORDER', + 'COURT_ORDER_FILING_TEMPLATE', 'FILING_HEADER', 'FILING_TEMPLATE', 'FILINGS_WITH_TYPES', 'INCORPORATION', 'INCORPORATION_FILING_TEMPLATE', + 'REGISTRARS_NOTATION', + 'REGISTRARS_NOTATION_FILING_TEMPLATE', + 'REGISTRARS_ORDER', + 'REGISTRARS_ORDER_FILING_TEMPLATE', 'SPECIAL_RESOLUTION', 'STUB_FILING', 'VOLUNTARY_DISSOLUTION', diff --git a/src/registry_schemas/example_data/schema_data.py b/src/registry_schemas/example_data/schema_data.py index ea29b83..fb8b6d6 100644 --- a/src/registry_schemas/example_data/schema_data.py +++ b/src/registry_schemas/example_data/schema_data.py @@ -21,7 +21,7 @@ 'header': { 'name': 'annualReport', 'availableOnPaperOnly': False, - 'inColinOnly' : False, + 'inColinOnly': False, 'date': '2019-04-08', 'certifiedBy': 'full name', 'email': 'no_one@never.get', @@ -1123,7 +1123,22 @@ COURT_ORDER = { 'fileNumber': '#1234-5678/90', 'orderDate': '2021-01-30T09:56:01+08:00', - 'effectOfOrder': 'planOfArrangement' + 'effectOfOrder': 'planOfArrangement', + 'orderDetails': 'A note about order' +} + +REGISTRARS_NOTATION = { + 'fileNumber': '#1234-5678/90', + 'orderDate': '2021-01-30T09:56:01+08:00', + 'effectOfOrder': 'planOfArrangement', + 'orderDetails': 'A note about order' +} + +REGISTRARS_ORDER = { + 'fileNumber': '#1234-5678/90', + 'orderDate': '2021-01-30T09:56:01+08:00', + 'effectOfOrder': 'planOfArrangement', + 'orderDetails': 'A note about order' } ALTERATION = { @@ -1577,6 +1592,63 @@ } } +REGISTRARS_NOTATION_FILING_TEMPLATE = { + 'filing': { + 'header': { + 'name': 'registrarsNotation', + 'date': '2021-05-06', + 'certifiedBy': 'full name', + 'email': 'no_one@never.get', + 'filingId': 1 + }, + 'business': { + 'foundingDate': '2018-01-01T00:00:00+00:00', + 'identifier': 'U1234567', + 'legalName': 'legal name - Test', + 'legalType': 'BC' + }, + 'registrarsNotation': REGISTRARS_NOTATION + } +} + +REGISTRARS_ORDER_FILING_TEMPLATE = { + 'filing': { + 'header': { + 'name': 'registrarsOrder', + 'date': '2021-05-06', + 'certifiedBy': 'full name', + 'email': 'no_one@never.get', + 'filingId': 1 + }, + 'business': { + 'foundingDate': '2018-01-01T00:00:00+00:00', + 'identifier': 'U1234567', + 'legalName': 'legal name - Test', + 'legalType': 'BC' + }, + 'registrarsOrder': REGISTRARS_ORDER + } +} + +COURT_ORDER_FILING_TEMPLATE = { + 'filing': { + 'header': { + 'name': 'courtOrder', + 'date': '2021-05-06', + 'certifiedBy': 'full name', + 'email': 'no_one@never.get', + 'filingId': 1 + }, + 'business': { + 'foundingDate': '2018-01-01T00:00:00+00:00', + 'identifier': 'U1234567', + 'legalName': 'legal name - Test', + 'legalType': 'BC' + }, + 'courtOrder': COURT_ORDER + } +} + STUB_FILING = { } @@ -1602,7 +1674,10 @@ ('changeOfDirectors', CHANGE_OF_DIRECTORS_MAILING), # bcorp-specific version of filing ('alteration', ALTERATION), ('conversion', CONVERSION), - ('transition', TRANSITION) + ('transition', TRANSITION), + ('courtOrder', COURT_ORDER), + ('registrarsNotation', REGISTRARS_NOTATION), + ('registrarsOrder', REGISTRARS_ORDER) ] diff --git a/src/registry_schemas/schemas/court_order.json b/src/registry_schemas/schemas/court_order.json index 8ac92c2..431c36f 100644 --- a/src/registry_schemas/schemas/court_order.json +++ b/src/registry_schemas/schemas/court_order.json @@ -21,6 +21,12 @@ "type": "string", "minLength": 5, "maxLength": 500, + "description": "planOfArrangement" + }, + "orderDetails": { + "type": "string", + "minLength": 0, + "maxLength": 2000, "description": "A brief note to explain the purpose of the Court Order." } }, diff --git a/src/registry_schemas/schemas/filing.json b/src/registry_schemas/schemas/filing.json index 95b0d3f..68384ae 100644 --- a/src/registry_schemas/schemas/filing.json +++ b/src/registry_schemas/schemas/filing.json @@ -64,7 +64,10 @@ "correction", "alteration", "conversion", - "transition" + "transition", + "registrarsNotation", + "registrarsOrder", + "courtOrder" ] }, "availableOnPaperOnly": { @@ -194,6 +197,42 @@ } } } + }, + "court_order_property": { + "$id": "#court_order_property", + "type": "object", + "required": [ + "courtOrder" + ], + "properties": { + "courtOrder": { + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order" + } + } + }, + "registrars_notation_property": { + "$id": "#registrars_notation_property", + "type": "object", + "required": [ + "registrarsNotation" + ], + "properties": { + "registrarsNotation": { + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/registrars_notation" + } + } + }, + "registrars_order_property": { + "$id": "#registrars_order_property", + "type": "object", + "required": [ + "registrarsOrder" + ], + "properties": { + "registrarsOrder": { + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/registrars_order" + } + } } }, "type": "object", @@ -222,6 +261,54 @@ "then": { "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/business" } + }, + { + "if": { + "properties": { + "header": { + "properties": { + "name": { + "const": "courtOrder" + } + } + } + } + }, + "then": { + "$ref": "#/definitions/court_order_property" + } + }, + { + "if": { + "properties": { + "header": { + "properties": { + "name": { + "const": "registrarsNotation" + } + } + } + } + }, + "then": { + "$ref": "#/definitions/registrars_notation_property" + } + }, + { + "if": { + "properties": { + "header": { + "properties": { + "name": { + "const": "registrarsOrder" + } + } + } + } + }, + "then": { + "$ref": "#/definitions/registrars_order_property" + } } ], "anyOf": [ diff --git a/src/registry_schemas/schemas/registrars_notation.json b/src/registry_schemas/schemas/registrars_notation.json new file mode 100644 index 0000000..7d3b4ee --- /dev/null +++ b/src/registry_schemas/schemas/registrars_notation.json @@ -0,0 +1,36 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://bcrs.gov.bc.ca/.well_known/schemas/registrars_notation", + "type": "object", + "title": "Registrars Notation Information Schema", + "properties": { + "fileNumber": { + "type": "string", + "minLength": 5, + "maxLength": 20, + "description": "The court assigns each court order a unique file number up to 20 characters in length." + }, + "orderDate": { + "type": "string", + "description": "The date and time of the order.", + "format": "date-time", + "examples": ["1970-01-01T00:00:00+00:00"] + }, + "effectOfOrder": { + "type": "string", + "minLength": 5, + "maxLength": 500, + "description": "planOfArrangement" + }, + "orderDetails": { + "type": "string", + "minLength": 0, + "maxLength": 2000, + "description": "A brief note to explain the purpose of the order." + } + }, + "required": [ + "fileNumber" + ] +} diff --git a/src/registry_schemas/schemas/registrars_order.json b/src/registry_schemas/schemas/registrars_order.json new file mode 100644 index 0000000..bf8d108 --- /dev/null +++ b/src/registry_schemas/schemas/registrars_order.json @@ -0,0 +1,36 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://bcrs.gov.bc.ca/.well_known/schemas/registrars_order", + "type": "object", + "title": "Registrars Order Information Schema", + "properties": { + "fileNumber": { + "type": "string", + "minLength": 5, + "maxLength": 20, + "description": "The court assigns each court order a unique file number up to 20 characters in length." + }, + "orderDate": { + "type": "string", + "description": "The date and time of the order.", + "format": "date-time", + "examples": ["1970-01-01T00:00:00+00:00"] + }, + "effectOfOrder": { + "type": "string", + "minLength": 5, + "maxLength": 500, + "description": "planOfArrangement" + }, + "orderDetails": { + "type": "string", + "minLength": 0, + "maxLength": 2000, + "description": "A brief note to explain the purpose of the Order." + } + }, + "required": [ + "fileNumber" + ] +} diff --git a/src/registry_schemas/version.py b/src/registry_schemas/version.py index 0b1235b..890a8f7 100644 --- a/src/registry_schemas/version.py +++ b/src/registry_schemas/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '2.12.0' # pylint: disable=invalid-name +__version__ = '2.12.1' # pylint: disable=invalid-name diff --git a/tests/unit/schema_data.py b/tests/unit/schema_data.py index 67b2501..498f494 100644 --- a/tests/unit/schema_data.py +++ b/tests/unit/schema_data.py @@ -44,5 +44,7 @@ ('conversion.json'), ('transition.json'), ('diff.json'), - ('court_order.json') + ('court_order.json'), + ('registrars_notation.json'), + ('registrars_order.json') ] diff --git a/tests/unit/test_alteration.py b/tests/unit/test_alteration.py index 6dcc2ba..1e8a2c4 100644 --- a/tests/unit/test_alteration.py +++ b/tests/unit/test_alteration.py @@ -155,8 +155,13 @@ def test_validate_invalid_share_structure_alteration(): 'fileNumber': '12345', 'orderDate': '2021-01-30T09:56:01+08:00', 'effectOfOrder': invalid_effect_of_order - } for invalid_effect_of_order in ['abcd', ('a' * 501)] # long effectOfOrder - ] + } for invalid_effect_of_order in ['abcd', ('a' * 501)]], # long effectOfOrder + *[{ + 'fileNumber': '12345', + 'orderDate': '2021-01-30T09:56:01+08:00', + 'effectOfOrder': 'planOfArrangement', + 'orderDetails': invalid_order_details + } for invalid_order_details in [('a' * 2001)]], # long orderDetails ]) def test_validate_invalid_court_orders(invalid_court_order): """Assert not valid court orders.""" diff --git a/tests/unit/test_court_order.py b/tests/unit/test_court_order.py new file mode 100644 index 0000000..ed2d525 --- /dev/null +++ b/tests/unit/test_court_order.py @@ -0,0 +1,58 @@ +# Copyright © 2019 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 order schemas are valid.""" + +import copy + +from registry_schemas import validate +from registry_schemas.example_data import COURT_ORDER + + +def test_court_order_schema(): + """Assert that the JSONSchema validator is working.""" + is_valid, errors = validate(COURT_ORDER, 'court_order') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_validate_valid_court_order(): + """Assert valid if all of the required fields are present.""" + order_json = copy.deepcopy(COURT_ORDER) + del order_json['effectOfOrder'] + del order_json['orderDate'] + del order_json['orderDetails'] + + is_valid, errors = validate(order_json, 'court_order') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_validate_invalid_court_order(): + """Assert invalid if required fields are missing.""" + order_json = copy.deepcopy(COURT_ORDER) + del order_json['fileNumber'] + + is_valid, errors = validate(order_json, 'court_order') + + assert not is_valid diff --git a/tests/unit/test_filings.py b/tests/unit/test_filings.py index 33e2632..3e8e6b7 100644 --- a/tests/unit/test_filings.py +++ b/tests/unit/test_filings.py @@ -30,8 +30,11 @@ CHANGE_OF_DIRECTORS_MAILING, CONVERSION_FILING_TEMPLATE, CORP_CHANGE_OF_ADDRESS, + COURT_ORDER_FILING_TEMPLATE, FILING_HEADER, INCORPORATION_FILING_TEMPLATE, + REGISTRARS_NOTATION_FILING_TEMPLATE, + REGISTRARS_ORDER_FILING_TEMPLATE, ) @@ -328,6 +331,7 @@ def test_filing_paper(): assert is_valid + def test_filing_colin_only(): """Assert that a Colin Only filing is valid.""" filing = copy.deepcopy(FILING_HEADER) @@ -343,7 +347,6 @@ def test_filing_colin_only(): assert is_valid - def test_effective_date(): """Assert that the effective date is working correctly from a structural POV.""" filing = copy.deepcopy(FILING_HEADER) @@ -432,3 +435,57 @@ def test_invalid_conversion_filing_schema_with_no_business(): print(errors) assert not is_valid + + +def test_court_order_filing_schema(): + """Assert that the JSONSchema validator is working.""" + is_valid, errors = validate(COURT_ORDER_FILING_TEMPLATE, 'filing') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_registrars_notation_filing_schema(): + """Assert that the JSONSchema validator is working.""" + is_valid, errors = validate(REGISTRARS_NOTATION_FILING_TEMPLATE, 'filing') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_registrars_order_filing_schema(): + """Assert that the JSONSchema validator is working.""" + is_valid, errors = validate(REGISTRARS_ORDER_FILING_TEMPLATE, 'filing') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_invalid_order_filing_schema_with_no_order(): + """Assert that the JSONSchema validator is working.""" + court_order_json = COURT_ORDER_FILING_TEMPLATE + del court_order_json['filing']['courtOrder'] + is_valid, errors = validate(court_order_json, 'filing') + assert not is_valid + + registrars_notation_json = REGISTRARS_NOTATION_FILING_TEMPLATE + del registrars_notation_json['filing']['registrarsNotation'] + is_valid, errors = validate(registrars_notation_json, 'filing') + assert not is_valid + + registrars_order_json = REGISTRARS_ORDER_FILING_TEMPLATE + del registrars_order_json['filing']['registrarsOrder'] + is_valid, errors = validate(registrars_order_json, 'filing') + assert not is_valid