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

17941 add agm_location_change_schema #145

Merged
merged 11 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -20,6 +20,7 @@
from .schema_data import (
ADDRESS,
ADMIN_FREEZE,
AGM_LOCATION_CHANGE,
ALL_FILINGS,
ALTERATION,
ALTERATION_FILING_TEMPLATE,
Expand Down
13 changes: 13 additions & 0 deletions src/registry_schemas/example_data/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,19 @@
'freeze': True
}

AGM_LOCATION_CHANGE = {
'year': '2023',
'newAgmLocation': {
'streetAddress': 'mailing_address - address line one',
'streetAddressAdditional': '',
'addressCity': 'mailing_address city',
'addressCountry': 'CA',
'postalCode': 'H0H0H0',
'addressRegion': 'BC',
argush3 marked this conversation as resolved.
Show resolved Hide resolved
'additionalLocationDetails': ''
argush3 marked this conversation as resolved.
Show resolved Hide resolved
}
}

# 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
73 changes: 73 additions & 0 deletions src/registry_schemas/schemas/agm_location_change.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://bcrs.gov.bc.ca/.well_known/schemas/agm_location_change",
"type": "object",
"definitions": {},
"title": "AGM Location Change Information Schema",
"required": [
"agmLocationChange"
],
"properties": {
"agmLocationChange": {
"type": "object",
"required": [
"year",
"newAgmLocation"
],
"properties": {
"year": {
"type": "string",
"description": "Year of the AGM, Must be on or after incorporation year and cannot be future year."
},
"newAgmLocation": {
kialj876 marked this conversation as resolved.
Show resolved Hide resolved
"type": "object",
"description": "New AGM Location, Must be in B.C.",
vysakh-menon-aot marked this conversation as resolved.
Show resolved Hide resolved
"required": [
"streetAddress",
"addressCity",
"addressCountry",
"addressRegion",
"postalCode"
],
"properties": {
"streetAddress": {
"type": "string",
"maxLength": 50
},
"streetAddressAdditional": {
"type": [
"string",
"null"
],
"maxLength": 50
},
"addressCity": {
"type": "string",
"maxLength": 40
},
"addressCountry": {
"type": "string",
"enum": ["Canada", "CA"]
},
"addressRegion": {
"type": "string",
vysakh-menon-aot marked this conversation as resolved.
Show resolved Hide resolved
"enum": ["BC"],
"description": "Must be in B.C."
vysakh-menon-aot marked this conversation as resolved.
Show resolved Hide resolved
},
"postalCode": {
"type": "string",
"maxLength": 15
},
"additionalLocationDetails": {
"type": [
"string",
"null"
],
"maxLength": 2000
}
}
}
}
}
}
}
4 changes: 4 additions & 0 deletions src/registry_schemas/schemas/filing.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"enum": [
"adminFreeze",
"alteration",
"agmLocationChange",
"amalgamationApplication",
"amendedAGM",
"amendedAnnualReport",
Expand Down Expand Up @@ -237,6 +238,9 @@
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/admin_freeze"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/agm_location_change"
},
{
"$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/alteration"
},
Expand Down
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.11' # pylint: disable=invalid-name
__version__ = '2.18.12' # 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 @@ -19,6 +19,7 @@
TEST_SCHEMAS_DATA = [
('address.json'),
('admin_freeze.json'),
('agm_location_change.json'),
('affiliated_businesses.json'),
('agreement_type.json'),
('alteration.json'),
Expand Down
61 changes: 61 additions & 0 deletions tests/unit/test_agm_location_change.py
argush3 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright © 2019 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 agm location change schemas are valid."""
from registry_schemas import validate
from registry_schemas.example_data import AGM_LOCATION_CHANGE


def test_agm_location_change_schema():
"""Assert that the JSONSchema validator is working."""
alc_json = {'agmLocationChange': AGM_LOCATION_CHANGE}

is_valid, errors = validate(alc_json, 'agm_location_change')

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

assert is_valid


def test_validate_no_agm_year():
"""Assert that an year node is present in the agm location change."""
alc_json = {'agmLocationChange': AGM_LOCATION_CHANGE}
del alc_json['agmLocationChange']['year']

is_valid, errors = validate(alc_json, 'agm_location_change')

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

assert not is_valid

def test_validate_not_BC():
"""Assert that an address region node is BC in the agm location change."""
alc_json = {'agmLocationChange': AGM_LOCATION_CHANGE}
alc_json['agmLocationChange']['newAgmLocation']['addressRegion'] = 'ON'

updated_alc_json = alc_json

is_valid, errors = validate(updated_alc_json, 'agm_location_change')

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

assert not is_valid
Loading