Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

25036 putBackOff filing schema #171

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -65,6 +65,7 @@
INCORPORATION,
INCORPORATION_FILING_TEMPLATE,
NOTICE_OF_WITHDRAWAL,
PUT_BACK_OFF,
PUT_BACK_ON,
REGISTRARS_NOTATION,
REGISTRARS_NOTATION_FILING_TEMPLATE,
Expand Down
6 changes: 6 additions & 0 deletions src/registry_schemas/example_data/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2861,6 +2861,11 @@
'courtOrder': COURT_ORDER
}

PUT_BACK_OFF = {
'details': 'Some details',
'courtOrder': COURT_ORDER
}

ADMIN_FREEZE = {
'freeze': True
}
Expand Down Expand Up @@ -2916,6 +2921,7 @@
('continuationOut', CONTINUATION_OUT),
('registration', REGISTRATION),
('putBackOn', PUT_BACK_ON),
('putBackOff', PUT_BACK_OFF),
('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 @@ -70,6 +70,7 @@
"dissolved",
"incorporationApplication",
"noticeOfWithdrawal",
"putBackOff",
"putBackOn",
"registrarsNotation",
"registrarsOrder",
Expand Down Expand Up @@ -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"
},
Expand Down
26 changes: 26 additions & 0 deletions src/registry_schemas/schemas/put_back_off.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
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.31' # pylint: disable=invalid-name
__version__ = '2.18.32' # 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 @@ -54,6 +54,7 @@
('office.json'),
('party.json'),
('person.json'),
('put_back_off.json'),
('put_back_on.json'),
('registrars_notation.json'),
('registrars_order.json'),
Expand Down
106 changes: 106 additions & 0 deletions tests/unit/test_put_back_off.py
Original file line number Diff line number Diff line change
@@ -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
Loading