Skip to content

Commit

Permalink
Merge pull request #96 from ritvick/feature/12092
Browse files Browse the repository at this point in the history
12092 Support for put back on filing
  • Loading branch information
vysakh-menon-aot authored Jun 9, 2022
2 parents 6e722c8 + d31ed80 commit 0d01d82
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/registry_schemas/example_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
FIRMS_CONVERSION,
INCORPORATION,
INCORPORATION_FILING_TEMPLATE,
PUT_BACK_ON,
REGISTRARS_NOTATION,
REGISTRARS_NOTATION_FILING_TEMPLATE,
REGISTRARS_ORDER,
Expand Down Expand Up @@ -109,4 +110,5 @@
'TRANSITION',
'TRANSITION_FILING_TEMPLATE',
'UNMANAGED',
'PUT_BACK_ON',
]
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 @@ -2214,6 +2214,11 @@
'displayName': 'Some legacy filing.'
}

PUT_BACK_ON = {
'details': 'Some details',
'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 All @@ -2239,7 +2244,8 @@
('courtOrder', COURT_ORDER),
('registrarsNotation', REGISTRARS_NOTATION),
('registrarsOrder', REGISTRARS_ORDER),
('registration', REGISTRATION)
('registration', REGISTRATION),
('putBackOn', PUT_BACK_ON)
]


Expand Down
6 changes: 5 additions & 1 deletion src/registry_schemas/schemas/filing.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"specialResolution",
"transition",
"registrarsNotation",
"registrarsOrder"
"registrarsOrder",
"putBackOn"
]
},
"availableOnPaperOnly": {
Expand Down Expand Up @@ -282,6 +283,9 @@
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/unmanaged"
},
{
"$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_on.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_on",
"type": "object",
"definitions": {},
"title": "Put Back On Information Schema",
"required": [
"putBackOn"
],
"properties": {
"putBackOn": {
"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 @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '2.15.23' # pylint: disable=invalid-name
__version__ = '2.15.24' # 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,4 +54,5 @@
('transition.json'),
('unmanaged.json'),
('person.json'),
('put_back_on.json')
]
106 changes: 106 additions & 0 deletions tests/unit/test_put_back_on.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright © 2022 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 on schemas are valid."""
import copy

import pytest

from registry_schemas import validate
from registry_schemas.example_data import PUT_BACK_ON, FILING_HEADER


def test_minimal_put_back_on_schema():
"""Assert that the JSONSchema validator is working."""
filing = copy.deepcopy(FILING_HEADER)
filing['filing']['header']['name'] = 'putBackOn'
filing['filing']['putBackOn'] = PUT_BACK_ON

is_valid, errors = validate(filing, 'filing')

if errors:
for err in errors:
print(err.message)
print(errors)

assert is_valid


def test_put_back_on_schema():
"""Assert that the JSONSchema validator is working."""
legal_filing = {'putBackOn': PUT_BACK_ON}

is_valid, errors = validate(legal_filing, 'put_back_on')

if errors:
for err in errors:
print(err.message)
print(errors)

assert is_valid


def test_put_back_on_court_order():
"""Assert a valid court orders."""
legal_filing = {'putBackOn': copy.deepcopy(PUT_BACK_ON)}
legal_filing['putBackOn']['courtOrder'] = {
'fileNumber': '12345',
'effectOfOrder': 'planOfArrangement'
}

is_valid, errors = validate(legal_filing, 'put_back_on')

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 = {'putBackOn': copy.deepcopy(PUT_BACK_ON)}
legal_filing['putBackOn']['courtOrder'] = invalid_court_order

is_valid, errors = validate(legal_filing, 'put_back_on')

if errors:
for err in errors:
print(err.message)
print(errors)

assert not is_valid

0 comments on commit 0d01d82

Please sign in to comment.