From d0e851b79b5047be68a8b896621d811eb8436721 Mon Sep 17 00:00:00 2001 From: "vysakh.menon" Date: Fri, 7 May 2021 05:04:54 -0700 Subject: [PATCH 1/6] 4392 Schema Change for Notations --- src/registry_schemas/example_data/__init__.py | 4 +- .../example_data/schema_data.py | 69 +++++++++++++++++-- src/registry_schemas/schemas/alteration.json | 2 +- src/registry_schemas/schemas/filing.json | 33 ++++++++- .../schemas/{court_order.json => order.json} | 7 +- src/registry_schemas/version.py | 2 +- tests/unit/schema_data.py | 2 +- tests/unit/test_filings.py | 2 +- tests/unit/test_order.py | 58 ++++++++++++++++ 9 files changed, 166 insertions(+), 13 deletions(-) rename src/registry_schemas/schemas/{court_order.json => order.json} (83%) create mode 100644 tests/unit/test_order.py diff --git a/src/registry_schemas/example_data/__init__.py b/src/registry_schemas/example_data/__init__.py index 19ac28e..9b68fb2 100644 --- a/src/registry_schemas/example_data/__init__.py +++ b/src/registry_schemas/example_data/__init__.py @@ -36,12 +36,12 @@ CORRECTION_COD, CORRECTION_COMBINED_AR, CORRECTION_INCORPORATION, - COURT_ORDER, FILING_HEADER, FILING_TEMPLATE, FILINGS_WITH_TYPES, INCORPORATION, INCORPORATION_FILING_TEMPLATE, + ORDER, SPECIAL_RESOLUTION, STUB_FILING, TRANSITION, @@ -65,7 +65,7 @@ 'CORRECTION_COD', 'CORRECTION_COMBINED_AR', 'CORRECTION_INCORPORATION', - 'COURT_ORDER', + 'ORDER', 'FILING_HEADER', 'FILING_TEMPLATE', 'FILINGS_WITH_TYPES', diff --git a/src/registry_schemas/example_data/schema_data.py b/src/registry_schemas/example_data/schema_data.py index ea29b83..755a330 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', @@ -1120,10 +1120,11 @@ } } -COURT_ORDER = { +ORDER = { 'fileNumber': '#1234-5678/90', 'orderDate': '2021-01-30T09:56:01+08:00', - 'effectOfOrder': 'planOfArrangement' + 'effectOfOrder': 'A note about order', + 'planOfArrangement': True } ALTERATION = { @@ -1164,7 +1165,7 @@ 'contactPoint': { 'email': 'no_one@never.get' }, - 'courtOrder': COURT_ORDER + 'courtOrder': ORDER } CONVERSION = { @@ -1577,6 +1578,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' + }, + 'order': ORDER + } +} + +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' + }, + 'order': 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' + }, + 'order': ORDER + } +} + STUB_FILING = { } @@ -1618,3 +1676,6 @@ def _build_complete_filing(name, snippet): ALL_FILINGS.insert(0, ANNUAL_REPORT) ALL_FILINGS.insert(0, CORRECTION_COA) ALL_FILINGS.insert(0, CORRECTION_INCORPORATION) +ALL_FILINGS.insert(0, REGISTRARS_NOTATION_FILING_TEMPLATE) +ALL_FILINGS.insert(0, REGISTRARS_ORDER_FILING_TEMPLATE) +ALL_FILINGS.insert(0, COURT_ORDER_FILING_TEMPLATE) diff --git a/src/registry_schemas/schemas/alteration.json b/src/registry_schemas/schemas/alteration.json index 2a29674..12ae84f 100644 --- a/src/registry_schemas/schemas/alteration.json +++ b/src/registry_schemas/schemas/alteration.json @@ -25,7 +25,7 @@ "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/share_structure" }, "courtOrder": { - "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order" + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/order" } } } diff --git a/src/registry_schemas/schemas/filing.json b/src/registry_schemas/schemas/filing.json index 95b0d3f..faf33a8 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,18 @@ } } } + }, + "order_property": { + "$id": "#order_property", + "type": "object", + "required": [ + "order" + ], + "properties": { + "order": { + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/order" + } + } } }, "type": "object", @@ -222,6 +237,22 @@ "then": { "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/business" } + }, + { + "if": { + "properties": { + "header": { + "properties": { + "name": { + "enum": ["registrarsNotation", "registrarsOrder", "courtOrder"] + } + } + } + } + }, + "then": { + "$ref": "#/definitions/order_property" + } } ], "anyOf": [ diff --git a/src/registry_schemas/schemas/court_order.json b/src/registry_schemas/schemas/order.json similarity index 83% rename from src/registry_schemas/schemas/court_order.json rename to src/registry_schemas/schemas/order.json index 8ac92c2..5f1c410 100644 --- a/src/registry_schemas/schemas/court_order.json +++ b/src/registry_schemas/schemas/order.json @@ -1,7 +1,7 @@ { "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order", + "$id": "https://bcrs.gov.bc.ca/.well_known/schemas/order", "type": "object", "title": "Court Order Information Schema", "properties": { @@ -20,8 +20,11 @@ "effectOfOrder": { "type": "string", "minLength": 5, - "maxLength": 500, + "maxLength": 2000, "description": "A brief note to explain the purpose of the Court Order." + }, + "hasPlanOfArrangement": { + "type": "boolean" } }, "required": [ 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..2d45590 100644 --- a/tests/unit/schema_data.py +++ b/tests/unit/schema_data.py @@ -44,5 +44,5 @@ ('conversion.json'), ('transition.json'), ('diff.json'), - ('court_order.json') + ('order.json') ] diff --git a/tests/unit/test_filings.py b/tests/unit/test_filings.py index 33e2632..a169817 100644 --- a/tests/unit/test_filings.py +++ b/tests/unit/test_filings.py @@ -328,6 +328,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 +344,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) diff --git a/tests/unit/test_order.py b/tests/unit/test_order.py new file mode 100644 index 0000000..ff172ec --- /dev/null +++ b/tests/unit/test_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 ORDER + + +def test_order_schema(): + """Assert that the JSONSchema validator is working.""" + is_valid, errors = validate(ORDER, 'order') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_validate_valid_order(): + """Assert valid if all of the required fields are present.""" + order_json = copy.deepcopy(ORDER) + del order_json['effectOfOrder'] + del order_json['orderDate'] + del order_json['planOfArrangement'] + + is_valid, errors = validate(order_json, 'order') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_validate_invalid_order(): + """Assert invalid if required fields are missing.""" + order_json = copy.deepcopy(ORDER) + del order_json['fileNumber'] + + is_valid, errors = validate(order_json, 'order') + + assert not is_valid From fbe8eb55defe4cf98ab48494b05d9e2f2b75274d Mon Sep 17 00:00:00 2001 From: "vysakh.menon" Date: Fri, 7 May 2021 08:49:49 -0700 Subject: [PATCH 2/6] test update --- src/registry_schemas/example_data/__init__.py | 8 ++- tests/unit/test_filings.py | 57 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/registry_schemas/example_data/__init__.py b/src/registry_schemas/example_data/__init__.py index 9b68fb2..1520287 100644 --- a/src/registry_schemas/example_data/__init__.py +++ b/src/registry_schemas/example_data/__init__.py @@ -36,12 +36,15 @@ CORRECTION_COD, CORRECTION_COMBINED_AR, CORRECTION_INCORPORATION, + COURT_ORDER_FILING_TEMPLATE, FILING_HEADER, FILING_TEMPLATE, FILINGS_WITH_TYPES, INCORPORATION, INCORPORATION_FILING_TEMPLATE, ORDER, + REGISTRARS_NOTATION_FILING_TEMPLATE, + REGISTRARS_ORDER_FILING_TEMPLATE, SPECIAL_RESOLUTION, STUB_FILING, TRANSITION, @@ -65,12 +68,15 @@ 'CORRECTION_COD', 'CORRECTION_COMBINED_AR', 'CORRECTION_INCORPORATION', - 'ORDER', + 'COURT_ORDER_FILING_TEMPLATE', 'FILING_HEADER', 'FILING_TEMPLATE', 'FILINGS_WITH_TYPES', 'INCORPORATION', 'INCORPORATION_FILING_TEMPLATE', + 'ORDER', + 'REGISTRARS_NOTATION_FILING_TEMPLATE', + 'REGISTRARS_ORDER_FILING_TEMPLATE', 'SPECIAL_RESOLUTION', 'STUB_FILING', 'VOLUNTARY_DISSOLUTION', diff --git a/tests/unit/test_filings.py b/tests/unit/test_filings.py index a169817..928cf85 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, ) @@ -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']['order'] + is_valid, errors = validate(court_order_json, 'filing') + assert not is_valid + + court_order_json = REGISTRARS_NOTATION_FILING_TEMPLATE + del court_order_json['filing']['order'] + is_valid, errors = validate(court_order_json, 'filing') + assert not is_valid + + court_order_json = REGISTRARS_ORDER_FILING_TEMPLATE + del court_order_json['filing']['order'] + is_valid, errors = validate(court_order_json, 'filing') + assert not is_valid From 4bc01727d7ddb09296a5e3b5c57f12b2891b34a4 Mon Sep 17 00:00:00 2001 From: "vysakh.menon" Date: Fri, 7 May 2021 08:55:02 -0700 Subject: [PATCH 3/6] no message --- tests/unit/test_alteration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_alteration.py b/tests/unit/test_alteration.py index 6dcc2ba..bd64cd7 100644 --- a/tests/unit/test_alteration.py +++ b/tests/unit/test_alteration.py @@ -155,7 +155,7 @@ 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' * 2001)] # long effectOfOrder ] ]) def test_validate_invalid_court_orders(invalid_court_order): From 6261422b3835d74263081b9c6405c92d8ae13d9c Mon Sep 17 00:00:00 2001 From: "vysakh.menon" Date: Fri, 7 May 2021 10:49:33 -0700 Subject: [PATCH 4/6] no message --- src/registry_schemas/example_data/schema_data.py | 4 ++-- src/registry_schemas/schemas/order.json | 9 ++++++--- tests/unit/test_order.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/registry_schemas/example_data/schema_data.py b/src/registry_schemas/example_data/schema_data.py index 755a330..e80d5ba 100644 --- a/src/registry_schemas/example_data/schema_data.py +++ b/src/registry_schemas/example_data/schema_data.py @@ -1123,8 +1123,8 @@ ORDER = { 'fileNumber': '#1234-5678/90', 'orderDate': '2021-01-30T09:56:01+08:00', - 'effectOfOrder': 'A note about order', - 'planOfArrangement': True + 'effectOfOrder': 'planOfArrangement', + 'orderDetails': 'A note about order' } ALTERATION = { diff --git a/src/registry_schemas/schemas/order.json b/src/registry_schemas/schemas/order.json index 5f1c410..97ed944 100644 --- a/src/registry_schemas/schemas/order.json +++ b/src/registry_schemas/schemas/order.json @@ -20,11 +20,14 @@ "effectOfOrder": { "type": "string", "minLength": 5, + "maxLength": 500, + "description": "planOfArrangement" + }, + "orderDetails": { + "type": "string", + "minLength": 1, "maxLength": 2000, "description": "A brief note to explain the purpose of the Court Order." - }, - "hasPlanOfArrangement": { - "type": "boolean" } }, "required": [ diff --git a/tests/unit/test_order.py b/tests/unit/test_order.py index ff172ec..8181be7 100644 --- a/tests/unit/test_order.py +++ b/tests/unit/test_order.py @@ -36,7 +36,7 @@ def test_validate_valid_order(): order_json = copy.deepcopy(ORDER) del order_json['effectOfOrder'] del order_json['orderDate'] - del order_json['planOfArrangement'] + del order_json['orderDetails'] is_valid, errors = validate(order_json, 'order') From 48a9379d45f6d5e51dd0ac2c51071ce41c18a665 Mon Sep 17 00:00:00 2001 From: "vysakh.menon" Date: Fri, 7 May 2021 12:10:16 -0700 Subject: [PATCH 5/6] requested changes --- src/registry_schemas/example_data/__init__.py | 8 ++- .../example_data/schema_data.py | 32 ++++++--- src/registry_schemas/schemas/alteration.json | 2 +- .../schemas/{order.json => court_order.json} | 4 +- src/registry_schemas/schemas/filing.json | 70 +++++++++++++++++-- .../schemas/registrars_notation.json | 36 ++++++++++ .../schemas/registrars_order.json | 36 ++++++++++ tests/unit/schema_data.py | 4 +- tests/unit/test_alteration.py | 9 ++- .../{test_order.py => test_court_order.py} | 18 ++--- tests/unit/test_filings.py | 14 ++-- 11 files changed, 193 insertions(+), 40 deletions(-) rename src/registry_schemas/schemas/{order.json => court_order.json} (91%) create mode 100644 src/registry_schemas/schemas/registrars_notation.json create mode 100644 src/registry_schemas/schemas/registrars_order.json rename tests/unit/{test_order.py => test_court_order.py} (74%) diff --git a/src/registry_schemas/example_data/__init__.py b/src/registry_schemas/example_data/__init__.py index 1520287..a519dfd 100644 --- a/src/registry_schemas/example_data/__init__.py +++ b/src/registry_schemas/example_data/__init__.py @@ -36,14 +36,16 @@ CORRECTION_COD, CORRECTION_COMBINED_AR, CORRECTION_INCORPORATION, + COURT_ORDER, COURT_ORDER_FILING_TEMPLATE, FILING_HEADER, FILING_TEMPLATE, FILINGS_WITH_TYPES, INCORPORATION, INCORPORATION_FILING_TEMPLATE, - ORDER, + REGISTRARS_NOTATION, REGISTRARS_NOTATION_FILING_TEMPLATE, + REGISTRARS_ORDER, REGISTRARS_ORDER_FILING_TEMPLATE, SPECIAL_RESOLUTION, STUB_FILING, @@ -68,14 +70,16 @@ 'CORRECTION_COD', 'CORRECTION_COMBINED_AR', 'CORRECTION_INCORPORATION', + 'COURT_ORDER', 'COURT_ORDER_FILING_TEMPLATE', 'FILING_HEADER', 'FILING_TEMPLATE', 'FILINGS_WITH_TYPES', 'INCORPORATION', 'INCORPORATION_FILING_TEMPLATE', - 'ORDER', + 'REGISTRARS_NOTATION', 'REGISTRARS_NOTATION_FILING_TEMPLATE', + 'REGISTRARS_ORDER', 'REGISTRARS_ORDER_FILING_TEMPLATE', 'SPECIAL_RESOLUTION', 'STUB_FILING', diff --git a/src/registry_schemas/example_data/schema_data.py b/src/registry_schemas/example_data/schema_data.py index e80d5ba..fb8b6d6 100644 --- a/src/registry_schemas/example_data/schema_data.py +++ b/src/registry_schemas/example_data/schema_data.py @@ -1120,7 +1120,21 @@ } } -ORDER = { +COURT_ORDER = { + 'fileNumber': '#1234-5678/90', + 'orderDate': '2021-01-30T09:56:01+08:00', + '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', @@ -1165,7 +1179,7 @@ 'contactPoint': { 'email': 'no_one@never.get' }, - 'courtOrder': ORDER + 'courtOrder': COURT_ORDER } CONVERSION = { @@ -1593,7 +1607,7 @@ 'legalName': 'legal name - Test', 'legalType': 'BC' }, - 'order': ORDER + 'registrarsNotation': REGISTRARS_NOTATION } } @@ -1612,7 +1626,7 @@ 'legalName': 'legal name - Test', 'legalType': 'BC' }, - 'order': ORDER + 'registrarsOrder': REGISTRARS_ORDER } } @@ -1631,7 +1645,7 @@ 'legalName': 'legal name - Test', 'legalType': 'BC' }, - 'order': ORDER + 'courtOrder': COURT_ORDER } } @@ -1660,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) ] @@ -1676,6 +1693,3 @@ def _build_complete_filing(name, snippet): ALL_FILINGS.insert(0, ANNUAL_REPORT) ALL_FILINGS.insert(0, CORRECTION_COA) ALL_FILINGS.insert(0, CORRECTION_INCORPORATION) -ALL_FILINGS.insert(0, REGISTRARS_NOTATION_FILING_TEMPLATE) -ALL_FILINGS.insert(0, REGISTRARS_ORDER_FILING_TEMPLATE) -ALL_FILINGS.insert(0, COURT_ORDER_FILING_TEMPLATE) diff --git a/src/registry_schemas/schemas/alteration.json b/src/registry_schemas/schemas/alteration.json index 12ae84f..2a29674 100644 --- a/src/registry_schemas/schemas/alteration.json +++ b/src/registry_schemas/schemas/alteration.json @@ -25,7 +25,7 @@ "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/share_structure" }, "courtOrder": { - "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/order" + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order" } } } diff --git a/src/registry_schemas/schemas/order.json b/src/registry_schemas/schemas/court_order.json similarity index 91% rename from src/registry_schemas/schemas/order.json rename to src/registry_schemas/schemas/court_order.json index 97ed944..431c36f 100644 --- a/src/registry_schemas/schemas/order.json +++ b/src/registry_schemas/schemas/court_order.json @@ -1,7 +1,7 @@ { "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://bcrs.gov.bc.ca/.well_known/schemas/order", + "$id": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order", "type": "object", "title": "Court Order Information Schema", "properties": { @@ -25,7 +25,7 @@ }, "orderDetails": { "type": "string", - "minLength": 1, + "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 faf33a8..68384ae 100644 --- a/src/registry_schemas/schemas/filing.json +++ b/src/registry_schemas/schemas/filing.json @@ -198,15 +198,39 @@ } } }, - "order_property": { - "$id": "#order_property", + "court_order_property": { + "$id": "#court_order_property", "type": "object", "required": [ - "order" + "courtOrder" ], "properties": { - "order": { - "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/order" + "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" } } } @@ -244,14 +268,46 @@ "header": { "properties": { "name": { - "enum": ["registrarsNotation", "registrarsOrder", "courtOrder"] + "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/order_property" + "$ref": "#/definitions/registrars_order_property" } } ], 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/tests/unit/schema_data.py b/tests/unit/schema_data.py index 2d45590..498f494 100644 --- a/tests/unit/schema_data.py +++ b/tests/unit/schema_data.py @@ -44,5 +44,7 @@ ('conversion.json'), ('transition.json'), ('diff.json'), - ('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 bd64cd7..69af08a 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' * 2001)] # 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 ['abcd', ('a' * 2001)]], # long orderDetails ]) def test_validate_invalid_court_orders(invalid_court_order): """Assert not valid court orders.""" diff --git a/tests/unit/test_order.py b/tests/unit/test_court_order.py similarity index 74% rename from tests/unit/test_order.py rename to tests/unit/test_court_order.py index 8181be7..ed2d525 100644 --- a/tests/unit/test_order.py +++ b/tests/unit/test_court_order.py @@ -16,12 +16,12 @@ import copy from registry_schemas import validate -from registry_schemas.example_data import ORDER +from registry_schemas.example_data import COURT_ORDER -def test_order_schema(): +def test_court_order_schema(): """Assert that the JSONSchema validator is working.""" - is_valid, errors = validate(ORDER, 'order') + is_valid, errors = validate(COURT_ORDER, 'court_order') if errors: for err in errors: @@ -31,14 +31,14 @@ def test_order_schema(): assert is_valid -def test_validate_valid_order(): +def test_validate_valid_court_order(): """Assert valid if all of the required fields are present.""" - order_json = copy.deepcopy(ORDER) + order_json = copy.deepcopy(COURT_ORDER) del order_json['effectOfOrder'] del order_json['orderDate'] del order_json['orderDetails'] - is_valid, errors = validate(order_json, 'order') + is_valid, errors = validate(order_json, 'court_order') if errors: for err in errors: @@ -48,11 +48,11 @@ def test_validate_valid_order(): assert is_valid -def test_validate_invalid_order(): +def test_validate_invalid_court_order(): """Assert invalid if required fields are missing.""" - order_json = copy.deepcopy(ORDER) + order_json = copy.deepcopy(COURT_ORDER) del order_json['fileNumber'] - is_valid, errors = validate(order_json, 'order') + 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 928cf85..3e8e6b7 100644 --- a/tests/unit/test_filings.py +++ b/tests/unit/test_filings.py @@ -476,16 +476,16 @@ def test_registrars_order_filing_schema(): 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']['order'] + del court_order_json['filing']['courtOrder'] is_valid, errors = validate(court_order_json, 'filing') assert not is_valid - court_order_json = REGISTRARS_NOTATION_FILING_TEMPLATE - del court_order_json['filing']['order'] - is_valid, errors = validate(court_order_json, 'filing') + 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 - court_order_json = REGISTRARS_ORDER_FILING_TEMPLATE - del court_order_json['filing']['order'] - is_valid, errors = validate(court_order_json, 'filing') + 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 From 5a051a271078ef8ee77f1321797ff7e6b6f845f3 Mon Sep 17 00:00:00 2001 From: "vysakh.menon" Date: Fri, 7 May 2021 12:15:30 -0700 Subject: [PATCH 6/6] no message --- tests/unit/test_alteration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_alteration.py b/tests/unit/test_alteration.py index 69af08a..1e8a2c4 100644 --- a/tests/unit/test_alteration.py +++ b/tests/unit/test_alteration.py @@ -161,7 +161,7 @@ def test_validate_invalid_share_structure_alteration(): 'orderDate': '2021-01-30T09:56:01+08:00', 'effectOfOrder': 'planOfArrangement', 'orderDetails': invalid_order_details - } for invalid_order_details in ['abcd', ('a' * 2001)]], # long orderDetails + } for invalid_order_details in [('a' * 2001)]], # long orderDetails ]) def test_validate_invalid_court_orders(invalid_court_order): """Assert not valid court orders."""