Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot committed Aug 29, 2024
1 parent 4304875 commit 96b4162
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pytest
from registry_schemas.example_data import CHANGE_OF_REGISTRATION_TEMPLATE, REGISTRATION

from legal_api.models import Business
from legal_api.services import NaicsService, NameXService
from legal_api.services.filings.validations.change_of_registration import validate

Expand Down Expand Up @@ -92,19 +93,28 @@ def json(self):

def test_gp_change_of_registration(session):
"""Assert that the general partnership change of registration is valid."""
filing = copy.deepcopy(GP_CHANGE_OF_REGISTRATION)
business = Business(identifier=filing['filing']['business']['identifier'],
legal_type=filing['filing']['business']['legalType'])

with patch.object(NameXService, 'query_nr_number', return_value=MockResponse(nr_response)):
with patch.object(NaicsService, 'find_by_code', return_value=naics_response):
err = validate(GP_CHANGE_OF_REGISTRATION)
err = validate(business, filing)
assert not err


def test_sp_change_of_registration(session):
"""Assert that the sole proprietor change of registration is valid."""
nr_res = copy.deepcopy(nr_response)
nr_res['legalType'] = 'SP'

filing = copy.deepcopy(SP_CHANGE_OF_REGISTRATION)
business = Business(identifier=filing['filing']['business']['identifier'],
legal_type=filing['filing']['business']['legalType'])

with patch.object(NameXService, 'query_nr_number', return_value=MockResponse(nr_res)):
with patch.object(NaicsService, 'find_by_code', return_value=naics_response):
err = validate(SP_CHANGE_OF_REGISTRATION)
err = validate(business, filing)

assert not err

Expand All @@ -113,9 +123,14 @@ def test_dba_change_of_registration(session):
"""Assert that the dba change of registration is valid."""
nr_res = copy.deepcopy(nr_response)
nr_res['legalType'] = 'SP'

filing = copy.deepcopy(DBA_CHANGE_OF_REGISTRATION)
business = Business(identifier=filing['filing']['business']['identifier'],
legal_type=filing['filing']['business']['legalType'])

with patch.object(NameXService, 'query_nr_number', return_value=MockResponse(nr_res)):
with patch.object(NaicsService, 'find_by_code', return_value=naics_response):
err = validate(DBA_CHANGE_OF_REGISTRATION)
err = validate(business, filing)

assert not err

Expand All @@ -132,9 +147,13 @@ def test_invalid_nr_change_of_registration(session):
'consumptionDate': ''
}]
}

business = Business(identifier=filing['filing']['business']['identifier'],
legal_type=filing['filing']['business']['legalType'])

with patch.object(NameXService, 'query_nr_number', return_value=MockResponse(invalid_nr_response)):
with patch.object(NaicsService, 'find_by_code', return_value=naics_response):
err = validate(filing)
err = validate(business, filing)

assert err

Expand All @@ -154,11 +173,14 @@ def test_invalid_party(session, test_name, filing, expected_msg):
"""Assert that party is invalid."""
filing['filing']['changeOfRegistration']['parties'][0]['roles'] = []

business = Business(identifier=filing['filing']['business']['identifier'],
legal_type=filing['filing']['business']['legalType'])

nr_res = copy.deepcopy(nr_response)
nr_res['legalType'] = filing['filing']['changeOfRegistration']['nameRequest']['legalType']
with patch.object(NameXService, 'query_nr_number', return_value=MockResponse(nr_res)):
with patch.object(NaicsService, 'find_by_code', return_value=naics_response):
err = validate(filing)
err = validate(business, filing)

assert err
assert err.msg[0]['error'] == expected_msg
Expand All @@ -179,11 +201,14 @@ def test_invalid_business_address(session, test_name, filing):
filing['filing']['changeOfRegistration']['offices']['businessOffice']['deliveryAddress']['addressCountry'] = \
'invalid'

business = Business(identifier=filing['filing']['business']['identifier'],
legal_type=filing['filing']['business']['legalType'])

nr_res = copy.deepcopy(nr_response)
nr_res['legalType'] = filing['filing']['changeOfRegistration']['nameRequest']['legalType']
with patch.object(NameXService, 'query_nr_number', return_value=MockResponse(nr_res)):
with patch.object(NaicsService, 'find_by_code', return_value=naics_response):
err = validate(filing)
err = validate(business, filing)

assert err
assert err.msg[0]['error'] == "Address Region must be 'BC'."
Expand All @@ -208,9 +233,12 @@ def test_change_of_registration_court_orders(session, test_status, file_number,
court_order['fileNumber'] = file_number
filing['filing']['changeOfRegistration']['courtOrder'] = court_order

business = Business(identifier=filing['filing']['business']['identifier'],
legal_type=filing['filing']['business']['legalType'])

with patch.object(NameXService, 'query_nr_number', return_value=MockResponse(nr_response)):
with patch.object(NaicsService, 'find_by_code', return_value=naics_response):
err = validate(filing)
err = validate(business, filing)

# validate outcomes
if test_status == 'FAIL':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_dissolution_type(session, test_status, legal_type, dissolution_type,
identifier, expected_code, expected_msg): # pylint: disable=too-many-arguments
"""Assert that a VD can be validated."""
# setup
business = Business(identifier=identifier)
business = Business(identifier=identifier, legal_type=legal_type)

filing = copy.deepcopy(FILING_HEADER)
filing['filing']['header']['name'] = 'dissolution'
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_dissolution_statement_type(session, test_status, legal_type, dissolutio
identifier, expected_code, expected_msg): # pylint: disable=too-many-arguments
"""Assert that a VD can be validated."""
# setup
business = Business(identifier=identifier)
business = Business(identifier=identifier, legal_type=legal_type)

filing = copy.deepcopy(FILING_HEADER)
filing['filing']['header']['name'] = 'dissolution'
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_dissolution_address(session, test_status, legal_type, address_validatio
identifier, expected_code, expected_msg): # pylint: disable=too-many-arguments
"""Assert that a VD can be validated."""
# setup
business = Business(identifier=identifier)
business = Business(identifier=identifier, legal_type=legal_type)

filing = copy.deepcopy(FILING_HEADER)
filing['filing']['header']['name'] = 'dissolution'
Expand Down Expand Up @@ -187,7 +187,7 @@ def test_dissolution_special_resolution(session, test_name, legal_type, dissolut
"""Assert that special resolution can be validated."""
from legal_api.services.filings import validate
# setup
business = Business(identifier=identifier)
business = Business(identifier=identifier, legal_type=legal_type)

filing = copy.deepcopy(FILING_HEADER)
filing['filing']['header']['name'] = 'dissolution'
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_dissolution_affidavit(session, minio_server, test_name, legal_type, dis
identifier, expected_code, expected_msg): # pylint: disable=too-many-arguments
"""Assert that an affidavit can be validated."""
# setup
business = Business(identifier=identifier)
business = Business(identifier=identifier, legal_type=legal_type)

filing = copy.deepcopy(FILING_HEADER)
filing['filing']['header']['name'] = 'dissolution'
Expand Down

0 comments on commit 96b4162

Please sign in to comment.