@@ -32,7 +32,11 @@ def test_check_business(session, has_amalgamation, expected_warning):
3232 mock_filing .filing_json = {
3333 "filing" : {
3434 "amalgamationApplication" : {
35- "amalgamatingBusinesses" : [{"identifier" : "BC7654321" }]
35+ "amalgamatingBusinesses" : [{"identifier" : "BC7654321" }],
36+ "nameRequest" : {
37+ "legalName" : "NAMED AMALG CORP." ,
38+ "legalType" : "BC"
39+ }
3640 }
3741 }
3842 }
@@ -58,10 +62,47 @@ def test_check_business(session, has_amalgamation, expected_warning):
5862 assert isinstance (warning ['data' ]['amalgamationDate' ], datetime )
5963 assert warning ['data' ]['filingId' ] == "filing-id"
6064 assert warning ['data' ]['amalgamatingBusinesses' ] == [{"identifier" : "BC7654321" }]
65+ assert warning ['data' ]['resultingBusinessName' ] == "NAMED AMALG CORP."
6166 else :
6267 assert len (result ) == 0
6368
6469
70+ @pytest .mark .parametrize ("name_request, expected_resulting_name" , [
71+ # named amalgamation result - legalName present
72+ ({"legalName" : "NAMED AMALG CORP." , "legalType" : "BC" }, "NAMED AMALG CORP." ),
73+ # numbered amalgamation result - no legalName key at all
74+ ({"correctNameOption" : "correct-aml-numbered" , "legalType" : "BC" }, None ),
75+ # no nameRequest present at all
76+ ({}, None ),
77+ ])
78+ def test_check_business_amalgamation_resulting_name (session , name_request , expected_resulting_name ):
79+ """Test that resultingBusinessName reflects whether the amalgamation result is named or numbered."""
80+ business = factory_business (identifier = "BC1234567" )
81+
82+ mock_filing = Mock ()
83+ mock_filing .id = "filing-id"
84+ mock_filing .effective_date = datetime .now () + timedelta (days = 1 )
85+ mock_filing .payment_completion_date = datetime .now ()
86+ mock_filing .filing_json = {
87+ "filing" : {
88+ "amalgamationApplication" : {
89+ "amalgamatingBusinesses" : [{"identifier" : "BC7654321" }],
90+ "nameRequest" : name_request
91+ }
92+ }
93+ }
94+
95+ with patch ('business_model.models.business.Business.is_pending_amalgamating_business' , return_value = mock_filing ):
96+ warning = check_business (business , is_staff = True )[0 ]
97+
98+ assert warning ['data' ].get ('resultingBusinessName' ) == expected_resulting_name
99+
100+ if expected_resulting_name is None :
101+ assert 'resultingBusinessName' not in warning ['data' ]
102+ else :
103+ assert 'resultingBusinessName' in warning ['data' ]
104+
105+
65106def test_check_business_excludes_filing_id_for_non_staff (session ):
66107 """Test that filing ids are only included for staff users."""
67108 business = factory_business (identifier = "BC1234567" )
@@ -72,7 +113,11 @@ def test_check_business_excludes_filing_id_for_non_staff(session):
72113 filing_json = {
73114 "filing" : {
74115 "amalgamationApplication" : {
75- "amalgamatingBusinesses" : [{"identifier" : "BC7654321" }]
116+ "amalgamatingBusinesses" : [{"identifier" : "BC7654321" }],
117+ "nameRequest" : {
118+ "legalName" : "NAMED AMALG CORP." ,
119+ "legalType" : "BC"
120+ }
76121 }
77122 }
78123 }
@@ -83,5 +128,6 @@ def test_check_business_excludes_filing_id_for_non_staff(session):
83128
84129 assert warning ['data' ] == {
85130 "amalgamationDate" : mock_filing .effective_date ,
86- "amalgamatingBusinesses" : [{"identifier" : "BC7654321" }]
131+ "amalgamatingBusinesses" : [{"identifier" : "BC7654321" }],
132+ "resultingBusinessName" : "NAMED AMALG CORP."
87133 }
0 commit comments