diff --git a/legal-api/tests/unit/resources/v2/test_business_filings/test_filings.py b/legal-api/tests/unit/resources/v2/test_business_filings/test_filings.py index 749252806..f8459a237 100644 --- a/legal-api/tests/unit/resources/v2/test_business_filings/test_filings.py +++ b/legal-api/tests/unit/resources/v2/test_business_filings/test_filings.py @@ -1598,48 +1598,71 @@ def test_resubmit_filing_failed(session, client, jwt, filing_status, review_stat assert rv.status_code == HTTPStatus.UNAUTHORIZED @pytest.mark.parametrize( - 'legal_type, filing_type, filing_json', + 'test_name, legal_type, filing_type, filing_json, is_temp', [ - ('BC', 'incorporationApplication', INCORPORATION), - ('BEN', 'continuationIn', CONTINUATION_IN), - ('CBEN', 'amalgamationApplication', AMALGAMATION_APPLICATION) + ('T-BUSINESS-IA', 'BC', 'incorporationApplication', INCORPORATION, True), + ('T-BUSINESS-CONT-IN', 'BEN', 'continuationIn', CONTINUATION_IN, True), + ('T-BUSINESS-AMALGAMATION', 'CBEN', 'amalgamationApplication', AMALGAMATION_APPLICATION, True), + ('REGULAR-BUSINESS-COA', 'BC', 'changeOfAddress', CHANGE_OF_ADDRESS, False), + ('REGULAR-BUSINESS-CONT-ALTERATION', 'BEN', 'alteration', ALTERATION_FILING_TEMPLATE, False), + ('REGULAR-BUSINESS-DISSOLUTION', 'CBEN', 'dissolution', DISSOLUTION, False) ] ) -def test_notice_of_withdraw_filing_temporary_businesses(session, client, jwt, legal_type, filing_type, filing_json): +def test_notice_of_withdraw_filing(session, client, jwt, test_name, legal_type, filing_type, filing_json, is_temp): """Assert that notice of withdraw for new business filings can be filed""" - # create a FE new business filing today = datetime.utcnow().date() future_effective_date = today + timedelta(days=5) future_effective_date = future_effective_date.isoformat() - identifier = 'Tb31yQIuBw' - temp_reg = RegistrationBootstrap() - temp_reg._identifier = identifier - temp_reg.save() - json_data = copy.deepcopy(FILING_HEADER) - json_data['filing']['header']['name'] = filing_type - del json_data['filing']['business'] - filing_json = copy.deepcopy(filing_json) - filing_json['nameRequest']['legalType'] = legal_type - json_data['filing'][filing_type] = filing_json - new_business_filing = factory_pending_filing(None, json_data) - new_business_filing.temp_reg = identifier - new_business_filing.effective_date = future_effective_date - new_business_filing.payment_completion_date = datetime.utcnow().isoformat() - new_business_filing.save() - withdrawn_filing_id = new_business_filing.id + # create a FE new business filing + if is_temp: + identifier = 'Tb31yQIuBw' + temp_reg = RegistrationBootstrap() + temp_reg._identifier = identifier + temp_reg.save() + json_data = copy.deepcopy(FILING_HEADER) + json_data['filing']['header']['name'] = filing_type + del json_data['filing']['business'] + new_bus_filing_json = copy.deepcopy(filing_json) + new_bus_filing_json['nameRequest']['legalType'] = legal_type + json_data['filing'][filing_type] = new_bus_filing_json + new_business_filing = factory_pending_filing(None, json_data) + new_business_filing.temp_reg = identifier + new_business_filing.effective_date = future_effective_date + new_business_filing.payment_completion_date = datetime.utcnow().isoformat() + new_business_filing.save() + withdrawn_filing_id = new_business_filing.id + # create a regular business and file a FE filing + else: + identifier = 'BC1234567' + founding_date = datetime.utcnow() - timedelta(days=5) + business = factory_business(identifier=identifier, founding_date=founding_date, entity_type=legal_type) + filing_data_reg_business = copy.deepcopy(FILING_HEADER) + filing_data_reg_business['filing']['header']['name'] = filing_type + filing_data_reg_business['filing']['business']['identifier'] = identifier + filing_data_reg_business['filing']['business']['legalType'] = legal_type + fe_filing_json = copy.deepcopy(filing_json) + filing_data_reg_business['filing'][filing_type] = fe_filing_json + fe_filing = factory_pending_filing(business, filing_data_reg_business) + fe_filing.effective_date = future_effective_date + fe_filing.payment_completion_date = datetime.utcnow().isoformat() + fe_filing.save() + withdrawn_filing_id = fe_filing.id # test filing a notice of withdraw for a temporary business now_json_data = copy.deepcopy(FILING_HEADER) now_json_data['filing']['header']['name'] = 'noticeOfWithdrawal' - del now_json_data['filing']['business'] - now_json_data['filing']['business'] = { - "identifier": identifier, - "legalType": legal_type - } + if is_temp: + del now_json_data['filing']['business'] + now_json_data['filing']['business'] = { + "identifier": identifier, + "legalType": legal_type + } + else: + now_json_data['filing']['business']['identifier'] = identifier + now_json_data['filing']['business']['legalType'] = legal_type now_json_data['filing']['noticeOfWithdrawal'] = copy.deepcopy(SCHEMA_NOTICE_OF_WITHDRAWAL) now_json_data['filing']['noticeOfWithdrawal']['filingId'] = withdrawn_filing_id del now_json_data['filing']['header']['filingId'] - print(now_json_data) # Test validation OK rv_validation = client.post(f'/api/v2/businesses/{identifier}/filings?only_validate=true',