From 75649ae56f59fa19342a2927b8a7b9e1a310580c Mon Sep 17 00:00:00 2001 From: Kevin Zhang <54437031+kzdev420@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:35:27 -0400 Subject: [PATCH] 23347 notice_of_withdrawal (#168) * 23347 notice_of_withdrawal * udpate properties * fix misc * add filingId field * update type * fix test data * remove identifier * add more test --- src/registry_schemas/example_data/__init__.py | 1 + .../example_data/schema_data.py | 8 +- src/registry_schemas/schemas/filing.json | 4 + .../schemas/notice_of_withdrawal.json | 25 ++++++ src/registry_schemas/version.py | 2 +- tests/unit/schema_data.py | 1 + tests/unit/test_notice_of_withdrawal.py | 80 +++++++++++++++++++ 7 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 src/registry_schemas/schemas/notice_of_withdrawal.json create mode 100644 tests/unit/test_notice_of_withdrawal.py diff --git a/src/registry_schemas/example_data/__init__.py b/src/registry_schemas/example_data/__init__.py index f134bfe..d2cfc15 100644 --- a/src/registry_schemas/example_data/__init__.py +++ b/src/registry_schemas/example_data/__init__.py @@ -64,6 +64,7 @@ FIRMS_CONVERSION, INCORPORATION, INCORPORATION_FILING_TEMPLATE, + NOTICE_OF_WITHDRAWAL, 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 8a8f77e..8b4333f 100644 --- a/src/registry_schemas/example_data/schema_data.py +++ b/src/registry_schemas/example_data/schema_data.py @@ -2884,6 +2884,11 @@ 'expireDateApprovedExt': '2023-10-10' } +NOTICE_OF_WITHDRAWAL = { + 'filingId': 123, + 'courtOrder': COURT_ORDER +} + # build complete list of filings with names, for use in the generic test_valid_filing() test # - not including AR or correction because they are already complete filings rather than the others that are snippets # without header and business elements; prepended to list afterwards. @@ -2913,7 +2918,8 @@ ('continuationOut', CONTINUATION_OUT), ('registration', REGISTRATION), ('putBackOn', PUT_BACK_ON), - ('adminFreeze', ADMIN_FREEZE) + ('adminFreeze', ADMIN_FREEZE), + ('noticeOfWithdrawal', NOTICE_OF_WITHDRAWAL) ] diff --git a/src/registry_schemas/schemas/filing.json b/src/registry_schemas/schemas/filing.json index 2a28bad..53d63c8 100644 --- a/src/registry_schemas/schemas/filing.json +++ b/src/registry_schemas/schemas/filing.json @@ -69,6 +69,7 @@ "dissolution", "dissolved", "incorporationApplication", + "noticeOfWithdrawal", "putBackOn", "registrarsNotation", "registrarsOrder", @@ -295,6 +296,9 @@ { "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/incorporation_application" }, + { + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/notice_of_withdrawal" + }, { "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/put_back_on" }, diff --git a/src/registry_schemas/schemas/notice_of_withdrawal.json b/src/registry_schemas/schemas/notice_of_withdrawal.json new file mode 100644 index 0000000..19e8f07 --- /dev/null +++ b/src/registry_schemas/schemas/notice_of_withdrawal.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://bcrs.gov.bc.ca/.well_known/schemas/notice_of_withdrawal", + "type": "object", + "definitions": {}, + "title": "Notice of Withdrawal Filing", + "required": [ + "noticeOfWithdrawal" + ], + "properties": { + "noticeOfWithdrawal": { + "type": "object", + "required": [ + "filingId" + ], + "properties": { + "filingId": { + "type": "integer", + "title": "IDs for the FED filings." + }, + "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 631c5bb..dada5d0 100644 --- a/src/registry_schemas/version.py +++ b/src/registry_schemas/version.py @@ -23,4 +23,4 @@ """ -__version__ = '2.18.29' # pylint: disable=invalid-name +__version__ = '2.18.30' # pylint: disable=invalid-name diff --git a/tests/unit/schema_data.py b/tests/unit/schema_data.py index 50e8d85..62d681d 100644 --- a/tests/unit/schema_data.py +++ b/tests/unit/schema_data.py @@ -50,6 +50,7 @@ ('naics.json'), ('name_request.json'), ('name_translations.json'), + ('notice_of_withdrawal.json'), ('office.json'), ('party.json'), ('person.json'), diff --git a/tests/unit/test_notice_of_withdrawal.py b/tests/unit/test_notice_of_withdrawal.py new file mode 100644 index 0000000..fc95b8a --- /dev/null +++ b/tests/unit/test_notice_of_withdrawal.py @@ -0,0 +1,80 @@ +# 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 admin freeze on schemas are valid.""" +import copy + +import pytest + +from registry_schemas import validate +from registry_schemas.example_data import FILING_HEADER, NOTICE_OF_WITHDRAWAL + + +def test_minimal_notice_of_withdrawal(): + """Assert that the JSONSchema validator is working.""" + filing = copy.deepcopy(FILING_HEADER) + filing['filing']['header']['name'] = 'noticeOfWithdrawal' + filing['filing']['noticeOfWithdrawal'] = NOTICE_OF_WITHDRAWAL + + is_valid, errors = validate(filing, 'filing') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_notice_of_withdrawal_schema(): + """Assert that the JSONSchema validator is working.""" + legal_filing = {'noticeOfWithdrawal': NOTICE_OF_WITHDRAWAL} + + is_valid, errors = validate(legal_filing, 'notice_of_withdrawal') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_validate_no_filing_id(): + """Assert not valid if the filingId node is present.""" + legal_filing = {'noticeOfWithdrawal': NOTICE_OF_WITHDRAWAL} + del legal_filing['noticeOfWithdrawal']['filingId'] + + is_valid, errors = validate(legal_filing, 'notice_of_withdrawal') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert not is_valid + + +def test_invalid_filing_id(): + """Assert not valid that the filingId node is not integer.""" + legal_filing = {'noticeOfWithdrawal': NOTICE_OF_WITHDRAWAL} + legal_filing['noticeOfWithdrawal']['filingId'] = 'BC2343' + + is_valid, errors = validate(legal_filing, 'notice_of_withdrawal') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert not is_valid