Skip to content

Commit

Permalink
15123 allow BN15 or BN9 in taxId (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot authored Jan 27, 2023
1 parent 04c5101 commit a106bba
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/registry_schemas/schemas/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
"type": "string",
"title": "The Tax_id Schema",
"default": "",
"examples": ["123456789"],
"pattern": "^[0-9]{9}$"
"examples": ["123456789BC0001", "123456789"],
"pattern": "^[0-9]{9}[A-Z]{2}[0-9]{4}$|^[0-9]{9}$"
},
"state": {
"type": "string",
Expand Down
7 changes: 0 additions & 7 deletions src/registry_schemas/schemas/party.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@
"examples": ["CP1234567"],
"pattern": "^[A-Z]{1,3}[0-9]{7}$"
},
"taxId": {
"type": "string",
"title": "The CRA business number",
"default": "",
"examples": ["123456789"],
"pattern": "^[0-9]{9}$"
},
"email": {
"type": "string",
"format": "email"
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.16.2' # pylint: disable=invalid-name
__version__ = '2.16.3' # pylint: disable=invalid-name
29 changes: 29 additions & 0 deletions tests/unit/test_change_of_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"""Test Suite to ensure change of registration schemas are valid."""
import copy

import pytest

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

Expand Down Expand Up @@ -48,6 +50,33 @@ def test_filing_change_of_registration_schema():
assert is_valid


@pytest.mark.parametrize('tax_id, expected', [
('123456789BC0001', True),
('123456789', True),
('12345678', False),
('1234567890', False),
('123456789BC', False),
('123456789BC00', False),
('1234567890BC0001', False),
('123456789BC00011', False)
])
def test_filing_business_tax_id_schema(tax_id, expected):
"""Assert that the JSONSchema validator is working."""
filing = copy.deepcopy(FILING_HEADER)
filing['filing']['header']['name'] = 'changeOfRegistration'
filing['filing']['business']['taxId'] = tax_id
filing['filing']['changeOfRegistration'] = copy.deepcopy(CHANGE_OF_REGISTRATION)

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

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

assert is_valid == expected


def test_validate_valid_change_of_registration_with_any_required_element():
"""Assert valid if all of the required elements are present."""
change_of_registration_json = copy.deepcopy(CHANGE_OF_REGISTRATION)
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_dba_registration_schema():
'id': 2,
'organizationName': 'Xyz Inc.',
'identifier': 'BC1234567',
'taxId': '123456789',
'email': '[email protected]',
'partyType': 'organization'
},
Expand Down

0 comments on commit a106bba

Please sign in to comment.