From 7e3a1960b90358ac7ec052723b1e77cf898bbcab Mon Sep 17 00:00:00 2001 From: deetz99 Date: Tue, 3 Feb 2026 17:50:45 -0800 Subject: [PATCH] add default value to offices, update test --- .../change_of_liquidators.py | 2 +- .../test_filer/test_change_of_liquidators.py | 89 +++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/queue_services/business-filer/src/business_filer/filing_processors/change_of_liquidators.py b/queue_services/business-filer/src/business_filer/filing_processors/change_of_liquidators.py index 62bd02f9f5..f3ed3530e7 100644 --- a/queue_services/business-filer/src/business_filer/filing_processors/change_of_liquidators.py +++ b/queue_services/business-filer/src/business_filer/filing_processors/change_of_liquidators.py @@ -50,7 +50,7 @@ def process(business: Business, filing_rec: Filing, filing_meta: FilingMeta): """Render the changeOfLiquidators onto the business model objects.""" filing_json = copy.deepcopy(filing_rec.filing_json) relationships = filing_json["filing"]["changeOfLiquidators"].get("relationships") - offices = filing_json["filing"]["changeOfLiquidators"].get("offices") + offices = filing_json["filing"]["changeOfLiquidators"].get("offices", {}) if filing_rec.filing_sub_type == "intentToLiquidate": create_relationships(relationships, business, filing_rec) diff --git a/queue_services/business-filer/tests/unit/test_filer/test_change_of_liquidators.py b/queue_services/business-filer/tests/unit/test_filer/test_change_of_liquidators.py index 03c3741aae..a22d9eaed0 100644 --- a/queue_services/business-filer/tests/unit/test_filer/test_change_of_liquidators.py +++ b/queue_services/business-filer/tests/unit/test_filer/test_change_of_liquidators.py @@ -323,6 +323,95 @@ def test_process_col_filing(app, session, mocker): assert address.street == expected_mailing_street assert has_liquidation_office + # Test change address liquidators - no offices submitted + + new_address_delivery_no_offices = { + 'streetAddress': 'Changed Delivery No Offices', + 'streetAddressAdditional': '', + 'addressCity': 'Vancouver', + 'addressRegion': 'BC', + 'addressCountry': 'CA', + 'postalCode': 'V0N4Y8', + 'deliveryInstructions': '' + } + new_address_mailing_no_offices = { + 'streetAddress': 'Changed Mailing No Offices', + 'streetAddressAdditional': '', + 'addressCity': 'Vancouver', + 'addressRegion': 'BC', + 'addressCountry': 'CA', + 'postalCode': 'V0N4Y8', + 'deliveryInstructions': '' + } + filing['filing']['changeOfLiquidators'] = { + 'type': 'changeAddressLiquidator', + 'relationships': [ + { + 'entity': { + 'identifier': party_id_2 + }, + 'deliveryAddress': new_address_delivery_no_offices, + 'mailingAddress': new_address_mailing_no_offices + } + ], + # No offices in payload + # 'offices': {} + } + payment_id = str(random.SystemRandom().getrandbits(0x58)) + effective_date = datetime(2025, 10, 10, 10, 0, 0, tzinfo=timezone.utc) + filing_rec = create_filing(payment_id, filing, business.id) + filing_rec.effective_date = effective_date + filing_rec.save() + + # setup + filing_msg = FilingMessage(filing_identifier=filing_rec.id) + + # TEST + process_filing(filing_msg) + + # Get modified data + change_address_filing: Filing = Filing.find_by_id(filing_rec.id) + business: Business = Business.find_by_internal_id(business.id) + + # assert changes + assert change_address_filing.transaction_id + assert change_address_filing.business_id == business.id + assert change_address_filing.status == Filing.Status.COMPLETED.value + check_drs_publish(drs_publish_mock, app, business, change_address_filing, '') + drs_publish_mock.reset_mock() + + party_roles: list[PartyRole] = business.party_roles.all() + + assert len(party_roles) == 2 + + for role in party_roles: + if role.party_id == party_id_2: + delivery_address: Address = role.party.delivery_address + mailing_address: Address = role.party.mailing_address + assert delivery_address.address_type == 'delivery' + assert delivery_address.street == new_address_delivery_no_offices['streetAddress'] + assert mailing_address.address_type == 'mailing' + assert mailing_address.street == new_address_mailing_no_offices['streetAddress'] + + # Will still have offices from the previous changeAddressLiquidator filing + offices: list[Office] = business.offices.all() + assert len(offices) == 2 + has_liquidation_office = False + for office in offices: + if office.office_type == OfficeType.LIQUIDATION: + has_liquidation_office = True + officeAddresses: list[Address] = office.addresses.all() + assert len(officeAddresses) == 2 + expected_delivery_street = new_office['deliveryAddress']['streetAddress'] + expected_mailing_street = new_office['mailingAddress']['streetAddress'] + for address in officeAddresses: + if address.address_type == Address.DELIVERY: + assert address.street == expected_delivery_street + else: + assert address.address_type == Address.MAILING + assert address.street == expected_mailing_street + assert has_liquidation_office + # Test appoint liquidators new_relationship = {