diff --git a/src/registry_schemas/example_data/__init__.py b/src/registry_schemas/example_data/__init__.py index d2cfc15..f45be51 100644 --- a/src/registry_schemas/example_data/__init__.py +++ b/src/registry_schemas/example_data/__init__.py @@ -65,6 +65,7 @@ INCORPORATION, INCORPORATION_FILING_TEMPLATE, NOTICE_OF_WITHDRAWAL, + PUT_BACK_OFF, PUT_BACK_ON, REGISTRARS_NOTATION, REGISTRARS_NOTATION_FILING_TEMPLATE, diff --git a/src/registry_schemas/example_data/schema_data.py b/src/registry_schemas/example_data/schema_data.py index 33ca5c7..154d848 100644 --- a/src/registry_schemas/example_data/schema_data.py +++ b/src/registry_schemas/example_data/schema_data.py @@ -2861,6 +2861,11 @@ 'courtOrder': COURT_ORDER } +PUT_BACK_OFF = { + 'details': 'Some details', + 'courtOrder': COURT_ORDER +} + ADMIN_FREEZE = { 'freeze': True } @@ -2916,6 +2921,7 @@ ('continuationOut', CONTINUATION_OUT), ('registration', REGISTRATION), ('putBackOn', PUT_BACK_ON), + ('putBackOff', PUT_BACK_OFF), ('adminFreeze', ADMIN_FREEZE), ('noticeOfWithdrawal', NOTICE_OF_WITHDRAWAL) ] diff --git a/src/registry_schemas/schemas/filing.json b/src/registry_schemas/schemas/filing.json index 53d63c8..da6cee4 100644 --- a/src/registry_schemas/schemas/filing.json +++ b/src/registry_schemas/schemas/filing.json @@ -70,6 +70,7 @@ "dissolved", "incorporationApplication", "noticeOfWithdrawal", + "putBackOff", "putBackOn", "registrarsNotation", "registrarsOrder", @@ -299,6 +300,9 @@ { "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/notice_of_withdrawal" }, + { + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/put_back_off" + }, { "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/put_back_on" }, diff --git a/src/registry_schemas/schemas/put_back_off.json b/src/registry_schemas/schemas/put_back_off.json new file mode 100644 index 0000000..7bfb0ec --- /dev/null +++ b/src/registry_schemas/schemas/put_back_off.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://bcrs.gov.bc.ca/.well_known/schemas/put_back_off", + "type": "object", + "definitions": {}, + "title": "Put Back Off Information Schema", + "required": [ + "putBackOff" + ], + "properties": { + "putBackOff": { + "type": "object", + "properties": { + "details": { + "type": "string", + "minLength": 0, + "maxLength": 2000, + "description": "Details which will appear in the ledger entry" + }, + "courtOrder": { + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/court_order#/properties/courtOrder" + } + } + } + } +} diff --git a/src/registry_schemas/version.py b/src/registry_schemas/version.py index ef52fdf..4b86e45 100644 --- a/src/registry_schemas/version.py +++ b/src/registry_schemas/version.py @@ -23,4 +23,4 @@ """ -__version__ = '2.18.31' # pylint: disable=invalid-name +__version__ = '2.18.32' # pylint: disable=invalid-name diff --git a/tests/unit/schema_data.py b/tests/unit/schema_data.py index 62d681d..12716bf 100644 --- a/tests/unit/schema_data.py +++ b/tests/unit/schema_data.py @@ -54,6 +54,7 @@ ('office.json'), ('party.json'), ('person.json'), + ('put_back_off.json'), ('put_back_on.json'), ('registrars_notation.json'), ('registrars_order.json'), diff --git a/tests/unit/test_put_back_off.py b/tests/unit/test_put_back_off.py new file mode 100644 index 0000000..a75c869 --- /dev/null +++ b/tests/unit/test_put_back_off.py @@ -0,0 +1,106 @@ +# Copyright © 2024 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 put back off schemas are valid.""" +import copy + +import pytest + +from registry_schemas import validate +from registry_schemas.example_data import PUT_BACK_OFF, FILING_HEADER + + +def test_minimal_put_back_off_schema(): + """Assert that the JSONSchema validator is working.""" + filing = copy.deepcopy(FILING_HEADER) + filing['filing']['header']['name'] = 'putBackOff' + filing['filing']['putBackOff'] = PUT_BACK_OFF + + is_valid, errors = validate(filing, 'filing') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_put_back_off_schema(): + """Assert that the JSONSchema validator is working.""" + legal_filing = {'putBackOff': PUT_BACK_OFF} + + is_valid, errors = validate(legal_filing, 'put_back_off') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_put_back_off_court_order(): + """Assert a valid court orders.""" + legal_filing = {'putBackOff': copy.deepcopy(PUT_BACK_OFF)} + legal_filing['putBackOff']['courtOrder'] = { + 'fileNumber': '12345', + 'effectOfOrder': 'planOfArrangement' + } + + is_valid, errors = validate(legal_filing, 'put_back_off') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +@pytest.mark.parametrize('invalid_court_order', [ + *[{'orderDate': '2021-01-30T09:56:01+08:00', + 'effectOfOrder': 'invalid effect of order'}], + *[{ + 'fileNumber': invalid_file_number, + 'orderDate': '2021-01-30T09:56:01+08:00' + } for invalid_file_number in ['1234', '123456789012345678901']], + *[{ + 'fileNumber': '12345', + 'orderDate': invalid_order_date + } for invalid_order_date in ['2021-01-30T09:56:01', '2021-01-30']], + *[{ + 'fileNumber': '12345', + 'orderDate': '2021-01-30T09:56:01+08:00', + 'effectOfOrder': invalid_effect_of_order + } for invalid_effect_of_order in [('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.""" + legal_filing = {'putBackOff': copy.deepcopy(PUT_BACK_OFF)} + legal_filing['putBackOff']['courtOrder'] = invalid_court_order + + is_valid, errors = validate(legal_filing, 'put_back_off') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert not is_valid