diff --git a/src/registry_schemas/example_data/__init__.py b/src/registry_schemas/example_data/__init__.py index f26ea30..1403b9b 100644 --- a/src/registry_schemas/example_data/__init__.py +++ b/src/registry_schemas/example_data/__init__.py @@ -20,6 +20,7 @@ from .schema_data import ( ADDRESS, ADMIN_FREEZE, + AGM_LOCATION_CHANGE, ALL_FILINGS, ALTERATION, ALTERATION_FILING_TEMPLATE, diff --git a/src/registry_schemas/example_data/schema_data.py b/src/registry_schemas/example_data/schema_data.py index 922dc0f..6441a15 100644 --- a/src/registry_schemas/example_data/schema_data.py +++ b/src/registry_schemas/example_data/schema_data.py @@ -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': 'ON', + 'deliveryInstructions': '' + } +} + # 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. diff --git a/src/registry_schemas/schemas/agm_location_change.json b/src/registry_schemas/schemas/agm_location_change.json new file mode 100644 index 0000000..23b3150 --- /dev/null +++ b/src/registry_schemas/schemas/agm_location_change.json @@ -0,0 +1,28 @@ +{ + "$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": { + "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/address" + } + } + } + } +} diff --git a/src/registry_schemas/schemas/filing.json b/src/registry_schemas/schemas/filing.json index a569a44..8fc4bc0 100644 --- a/src/registry_schemas/schemas/filing.json +++ b/src/registry_schemas/schemas/filing.json @@ -47,6 +47,7 @@ "enum": [ "adminFreeze", "alteration", + "agmLocationChange", "amalgamationApplication", "amendedAGM", "amendedAnnualReport", @@ -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" }, diff --git a/src/registry_schemas/version.py b/src/registry_schemas/version.py index 52a1d83..75c0e3b 100644 --- a/src/registry_schemas/version.py +++ b/src/registry_schemas/version.py @@ -23,4 +23,4 @@ """ -__version__ = '2.18.11' # pylint: disable=invalid-name +__version__ = '2.18.12' # pylint: disable=invalid-name diff --git a/tests/unit/schema_data.py b/tests/unit/schema_data.py index 2191eaf..b79c8bc 100644 --- a/tests/unit/schema_data.py +++ b/tests/unit/schema_data.py @@ -19,6 +19,7 @@ TEST_SCHEMAS_DATA = [ ('address.json'), ('admin_freeze.json'), + ('agm_location_change.json'), ('affiliated_businesses.json'), ('agreement_type.json'), ('alteration.json'), diff --git a/tests/unit/test_agm_location_change.py b/tests/unit/test_agm_location_change.py new file mode 100644 index 0000000..e70fc0f --- /dev/null +++ b/tests/unit/test_agm_location_change.py @@ -0,0 +1,80 @@ +# 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.""" +import copy +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.""" + agm_location_change = copy.deepcopy(AGM_LOCATION_CHANGE) + alc_json = {'agmLocationChange': copy.deepcopy(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.""" + agm_location_change = copy.deepcopy(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_no_agm_location(): + """Assert that an newAgmLocation node is present in the agm location change.""" + agm_location_change = copy.deepcopy(AGM_LOCATION_CHANGE) + alc_json = {'agmLocationChange': agm_location_change} + del alc_json['agmLocationChange']['newAgmLocation'] + + 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_no_agm_address(): + """Assert that an streetAddress node is present in the agm location change.""" + agm_location_change = copy.deepcopy(AGM_LOCATION_CHANGE) + alc_json = {'agmLocationChange': agm_location_change} + del alc_json['agmLocationChange']['newAgmLocation']['streetAddress'] + + is_valid, errors = validate(alc_json, 'agm_location_change') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert not is_valid