@@ -2250,7 +2250,8 @@ def test_foreign_business_region_bc_rejected(mocker, app, session, jwt):
22502250 'corrected outside of this filing before this amalgamation can be filed.' )
22512251
22522252
2253- def _factory_short_form_source_business (identifier = 'BC7654321' , share_class_name = 'Class A Shares' ):
2253+ def _factory_short_form_source_business (identifier = 'BC7654321' , share_class_name = 'Class A Shares' ,
2254+ middle_initial = None ):
22542255 """Create a holding/primary business with offices, a director, shares and a resolution."""
22552256 business = factory_business (identifier , entity_type = Business .LegalTypes .COMP .value )
22562257 for office_type in ['registeredOffice' , 'recordsOffice' ]:
@@ -2271,7 +2272,8 @@ def _factory_short_form_source_business(identifier='BC7654321', share_class_name
22712272 business .resolutions .append (Resolution (resolution_date = date (2020 , 5 , 13 ),
22722273 resolution_type = Resolution .ResolutionType .SPECIAL .value ))
22732274
2274- party = Party (first_name = 'DIRECTOR' , last_name = 'ONE' , party_type = Party .PartyTypes .PERSON .value )
2275+ party = Party (first_name = 'DIRECTOR' , middle_initial = middle_initial , last_name = 'ONE' ,
2276+ party_type = Party .PartyTypes .PERSON .value )
22752277 party .delivery_address = factory_address (f'{ identifier } director street' , 'delivery' )
22762278 party .save ()
22772279 business .party_roles .append (PartyRole (role = PartyRole .RoleTypes .DIRECTOR .value ,
@@ -2365,6 +2367,31 @@ def test_short_form_match_lear(app, session, jwt, test_status, expected_msg):
23652367 assert expected_msg in [x ['error' ] for x in err .msg ]
23662368
23672369
2370+ @pytest .mark .parametrize ('test_status' , ['SUCCESS' , 'MISMATCH' ])
2371+ def test_short_form_match_director_middle_name (app , session , jwt , test_status ):
2372+ """Assert the comparator accepts the UI's officer "middleName" against the source's "middleInitial"."""
2373+ account_id = '123456'
2374+ holding = _factory_short_form_source_business (middle_initial = 'M' )
2375+ factory_business ('BC1111111' , entity_type = Business .LegalTypes .COMP .value )
2376+ filing = _short_form_filing_from_lear (holding )
2377+ aml = filing ['filing' ]['amalgamationApplication' ]
2378+
2379+ # the UI submits directors with "middleName" (renamed from the API's "middleInitial")
2380+ for party in aml ['parties' ]:
2381+ officer = party ['officer' ]
2382+ if officer .pop ('middleInitial' , None ):
2383+ officer ['middleName' ] = 'M' if test_status == 'SUCCESS' else 'X'
2384+
2385+ with jwt_request_context (app , jwt , [STAFF_ROLE ], 'staff-user' , account_id ):
2386+ err = validate (None , filing , account_id )
2387+
2388+ if test_status == 'SUCCESS' :
2389+ assert not err , err .msg
2390+ else :
2391+ assert f"Directors do not match the holding business's current directors. { REFRESH_HINT } " in \
2392+ [x ['error' ] for x in err .msg ]
2393+
2394+
23682395def test_short_form_match_lear_ignores_db_artifacts (app , session , jwt ):
23692396 """Assert ids, priorities and numeric formatting differences do not fail the match."""
23702397 account_id = '123456'
0 commit comments