Skip to content

Commit

Permalink
18162 AGM Location Change - part 2 (bcgov#146)
Browse files Browse the repository at this point in the history
* 18162 AGM Location Change II

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* fix

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* update max len of AGM location

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* fix test

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

---------

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>
  • Loading branch information
chenhongjing authored and JazzarKarim committed Jan 31, 2024
1 parent 6f2a203 commit ad243a7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 18 deletions.
11 changes: 2 additions & 9 deletions src/registry_schemas/example_data/schema_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2723,15 +2723,8 @@

AGM_LOCATION_CHANGE = {
'year': '2023',
'newAgmLocation': {
'streetAddress': 'mailing_address - address line one',
'streetAddressAdditional': '',
'addressCity': 'mailing_address city',
'addressCountry': 'CA',
'postalCode': 'H0H0H0',
'addressRegion': 'ON',
'deliveryInstructions': ''
}
'reason': 'Some reasons',
'agmLocation': 'Red Deer, Alberta, Canada'
}

# build complete list of filings with names, for use in the generic test_valid_filing() test
Expand Down
12 changes: 9 additions & 3 deletions src/registry_schemas/schemas/agm_location_change.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
"type": "object",
"required": [
"year",
"newAgmLocation"
"reason",
"agmLocation"
],
"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"
"reason":{
"type": "string",
"maxLength": 2000
},
"agmLocation": {
"type": "string",
"maxLength": 400
}
}
}
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.13' # pylint: disable=invalid-name
__version__ = '2.18.14' # pylint: disable=invalid-name
42 changes: 37 additions & 5 deletions tests/unit/test_agm_location_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,43 @@ def test_validate_no_agm_year():
assert not is_valid


def test_validate_no_reason():
"""Assert that a reason 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']['reason']

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."""
"""Assert that an agmLocation 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']['agmLocation']

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_invalid_reason():
"""Assert not valid if reason exceeds maximum length."""
agm_location_change = copy.deepcopy(AGM_LOCATION_CHANGE)
alc_json = {'agmLocationChange': agm_location_change}
del alc_json['agmLocationChange']['newAgmLocation']
alc_json['agmLocationChange']['reason'] = 'a'*2001

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

Expand All @@ -64,11 +96,11 @@ def test_validate_no_agm_location():
assert not is_valid


def test_validate_no_agm_address():
"""Assert that an streetAddress node is present in the agm location change."""
def test_validate_invalid_agm_location():
"""Assert not valid if agmLocation exceeds maximum length."""
agm_location_change = copy.deepcopy(AGM_LOCATION_CHANGE)
alc_json = {'agmLocationChange': agm_location_change}
del alc_json['agmLocationChange']['newAgmLocation']['streetAddress']
alc_json['agmLocationChange']['agmLocation'] = 'a'*401

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

Expand Down

0 comments on commit ad243a7

Please sign in to comment.