Skip to content

Commit

Permalink
23347 notice_of_withdrawal (#168)
Browse files Browse the repository at this point in the history
* 23347 notice_of_withdrawal

* udpate properties

* fix misc

* add filingId field

* update type

* fix test data

* remove identifier

* add more test
  • Loading branch information
kzdev420 authored Oct 3, 2024
1 parent 57a116d commit 75649ae
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 2 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 @@ -64,6 +64,7 @@
FIRMS_CONVERSION,
INCORPORATION,
INCORPORATION_FILING_TEMPLATE,
NOTICE_OF_WITHDRAWAL,
PUT_BACK_ON,
REGISTRARS_NOTATION,
REGISTRARS_NOTATION_FILING_TEMPLATE,
Expand Down
8 changes: 7 additions & 1 deletion src/registry_schemas/example_data/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -2913,7 +2918,8 @@
('continuationOut', CONTINUATION_OUT),
('registration', REGISTRATION),
('putBackOn', PUT_BACK_ON),
('adminFreeze', ADMIN_FREEZE)
('adminFreeze', ADMIN_FREEZE),
('noticeOfWithdrawal', NOTICE_OF_WITHDRAWAL)
]


Expand Down
4 changes: 4 additions & 0 deletions src/registry_schemas/schemas/filing.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"dissolution",
"dissolved",
"incorporationApplication",
"noticeOfWithdrawal",
"putBackOn",
"registrarsNotation",
"registrarsOrder",
Expand Down Expand Up @@ -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"
},
Expand Down
25 changes: 25 additions & 0 deletions src/registry_schemas/schemas/notice_of_withdrawal.json
Original file line number Diff line number Diff line change
@@ -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" }
}
}
}
}
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.18.29' # pylint: disable=invalid-name
__version__ = '2.18.30' # 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 @@ -50,6 +50,7 @@
('naics.json'),
('name_request.json'),
('name_translations.json'),
('notice_of_withdrawal.json'),
('office.json'),
('party.json'),
('person.json'),
Expand Down
80 changes: 80 additions & 0 deletions tests/unit/test_notice_of_withdrawal.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 75649ae

Please sign in to comment.