@@ -293,7 +293,7 @@ def delete_all_lots_and_experiments(self):
293
293
if len (lots ) > 0 :
294
294
# Delete any remaining lots not from bulk loads
295
295
for lot in lots :
296
- self .client .delete_lot (lot ['lotCorpName' ])
296
+ self .client .delete_lot (lot ['lotCorpName' ], raise_on_linked_data = False )
297
297
298
298
def requires_basic_cmpd_reg_load (func ):
299
299
"""
@@ -3314,13 +3314,13 @@ def test_004_delete_lot(self, experiment):
3314
3314
acas_admin = self .create_and_connect_backdoor_user (prefix = "acas-admin-" , acas_user = True , acas_admin = True , creg_user = False , creg_admin = False )
3315
3315
cmpdreg_admin = self .create_and_connect_backdoor_user (prefix = "cmpdreg-admin-" , acas_user = False , acas_admin = False , creg_user = True , creg_admin = True )
3316
3316
3317
- def can_delete_lot (self , user_client , lot_corp_name , set_owner_first = True ):
3317
+ def can_delete_lot (self , user_client , lot_corp_name , set_owner_first = True , raise_on_linked_data = False ):
3318
3318
if set_owner_first :
3319
3319
meta_lot = self .client .get_meta_lot (lot_corp_name )
3320
3320
meta_lot ["lot" ]["chemist" ] = user_client .username
3321
3321
self .client .save_meta_lot (meta_lot )
3322
3322
try :
3323
- response = user_client .delete_lot (lot_corp_name )
3323
+ response = user_client .delete_lot (lot_corp_name , raise_on_linked_data = raise_on_linked_data )
3324
3324
except requests .HTTPError :
3325
3325
return False
3326
3326
self .assertIn ("success" , response )
@@ -3364,7 +3364,12 @@ def can_delete_lot(self, user_client, lot_corp_name, set_owner_first=True):
3364
3364
self .assertFalse (can_delete_lot (self , acas_admin , restricted_lot_corp_name , set_owner_first = True ))
3365
3365
3366
3366
# Allow rule: CregAdmin/ACASAdmin can delete the lot and assay data
3367
- self .assertTrue (can_delete_lot (self , self .client , restricted_lot_corp_name , set_owner_first = True ))
3367
+ # First verify that raise_on_linked_data=True will raise an error
3368
+ with self .assertRaises (ValueError ) as context :
3369
+ can_delete_lot (self , self .client , restricted_lot_corp_name , set_owner_first = True , raise_on_linked_data = True )
3370
+ self .assertIn ('Refusing to delete lot' , str (context .exception ))
3371
+ # Now actually delete the lot
3372
+ self .assertTrue (can_delete_lot (self , self .client , restricted_lot_corp_name , set_owner_first = True , raise_on_linked_data = False ))
3368
3373
3369
3374
# Verify lot is actually deleted
3370
3375
meta_lot = self .client .get_meta_lot (restricted_lot_corp_name )
0 commit comments