Skip to content

Commit

Permalink
Merge branch 'main' into 17796
Browse files Browse the repository at this point in the history
  • Loading branch information
chenhongjing authored Oct 11, 2023
2 parents bd5dceb + a9fadf7 commit 3700f27
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 1 deletion.
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
15 changes: 14 additions & 1 deletion src/registry_schemas/example_data/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,7 @@
},
'roles': [
{
'roleType': 'Director',
'roleType': 'Completing Party',
'appointmentDate': '2018-01-01'
}
]
Expand Down 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': '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.
Expand Down
28 changes: 28 additions & 0 deletions src/registry_schemas/schemas/agm_location_change.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
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
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
80 changes: 80 additions & 0 deletions tests/unit/test_agm_location_change.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3700f27

Please sign in to comment.