@@ -1245,7 +1245,7 @@ def test_status_transition(self):
12451245 )
12461246 # Snapshot Shouldn't have the updated checklist file
12471247 self .assertFalse (
1248- second_snapshot .updated_checklist_file . name ,
1248+ second_snapshot .updated_checklist_file ,
12491249 "Latest Snapshot shouldn't have the updated checklist file." ,
12501250 )
12511251 # Check if the latest_simplified_eap is updated in EAPRegistration
@@ -1268,14 +1268,18 @@ def test_status_transition(self):
12681268 # Upload updated checklist file
12691269 # UPDATES on the second snapshot
12701270 url = f"/api/v2/simplified-eap/{ second_snapshot .id } /"
1271- with tempfile .NamedTemporaryFile (suffix = ".xlsx" ) as tmp_file :
1272- tmp_file .write (b"Updated Test content" )
1273- tmp_file .seek (0 )
1274-
1275- file_data = {"eap_registration" : second_snapshot .eap_registration_id , "updated_checklist_file" : tmp_file }
1271+ checklist_file_instance = EAPFileFactory ._create_file (
1272+ created_by = self .country_admin ,
1273+ modified_by = self .country_admin ,
1274+ )
1275+ file_data = {
1276+ "prioritized_hazard_and_impact" : "Floods with potential heavy impact." ,
1277+ "eap_registration" : second_snapshot .eap_registration_id ,
1278+ "updated_checklist_file" : checklist_file_instance .id ,
1279+ }
12761280
1277- response = self .client .patch (url , file_data , format = "multipart " )
1278- self .assertEqual (response .status_code , 200 , response .data )
1281+ response = self .client .patch (url , file_data , format = "json " )
1282+ self .assertEqual (response .status_code , 200 , response .data )
12791283
12801284 # SUCCESS:
12811285 self .authenticate (self .country_admin )
@@ -1336,7 +1340,7 @@ def test_status_transition(self):
13361340 self .assertTrue (second_snapshot .is_locked )
13371341 # Snapshot Shouldn't have the updated checklist file
13381342 self .assertFalse (
1339- third_snapshot .updated_checklist_file . name ,
1343+ third_snapshot .updated_checklist_file ,
13401344 "Latest snapshot shouldn't have the updated checklist file." ,
13411345 )
13421346
@@ -1356,14 +1360,17 @@ def test_status_transition(self):
13561360 # Upload updated checklist file
13571361 # UPDATES on the second snapshot
13581362 url = f"/api/v2/simplified-eap/{ third_snapshot .id } /"
1359- with tempfile .NamedTemporaryFile (suffix = ".xlsx" ) as tmp_file :
1360- tmp_file .write (b"Updated Test content" )
1361- tmp_file .seek (0 )
1362-
1363- file_data = {"eap_registration" : third_snapshot .eap_registration_id , "updated_checklist_file" : tmp_file }
1363+ file_data = {
1364+ "prioritized_hazard_and_impact" : "Floods with potential heavy impact." ,
1365+ "risks_selected_protocols" : "Protocol A and Protocol B." ,
1366+ "selected_early_actions" : "The early actions selected." ,
1367+ "overall_objective_intervention" : "To reduce risks through early actions." ,
1368+ "eap_registration" : third_snapshot .eap_registration_id ,
1369+ "updated_checklist_file" : checklist_file_instance .id ,
1370+ }
13641371
1365- response = self .client .patch (url , file_data , format = "multipart " )
1366- self .assertEqual (response .status_code , 200 )
1372+ response = self .client .patch (url , file_data , format = "json " )
1373+ self .assertEqual (response .status_code , 200 )
13671374
13681375 # SUCCESS:
13691376 self .authenticate (self .country_admin )
@@ -1444,7 +1451,7 @@ def test_status_transition(self):
14441451 self .assertTrue (third_snapshot .is_locked )
14451452 # Snapshot Shouldn't have the updated checklist file
14461453 self .assertFalse (
1447- fourth_snapshot .updated_checklist_file . name ,
1454+ fourth_snapshot .updated_checklist_file ,
14481455 "Latest snapshot shouldn't have the updated checklist file." ,
14491456 )
14501457
@@ -1466,21 +1473,17 @@ def test_status_transition(self):
14661473 # Upload updated checklist file
14671474 # UPDATES on the second snapshot
14681475 url = f"/api/v2/simplified-eap/{ fourth_snapshot .id } /"
1469- with tempfile .NamedTemporaryFile (suffix = ".xlsx" ) as tmp_file :
1470- tmp_file .write (b"Updated Test content" )
1471- tmp_file .seek (0 )
1476+ file_data = {
1477+ "prioritized_hazard_and_impact" : "Floods with potential heavy impact." ,
1478+ "risks_selected_protocols" : "Protocol A and Protocol B." ,
1479+ "selected_early_actions" : "The early actions selected." ,
1480+ "overall_objective_intervention" : "To reduce risks through early actions." ,
1481+ "eap_registration" : third_snapshot .eap_registration_id ,
1482+ "updated_checklist_file" : checklist_file_instance .id ,
1483+ }
14721484
1473- file_data = {
1474- "prioritized_hazard_and_impact" : "Floods with potential heavy impact." ,
1475- "risks_selected_protocols" : "Protocol A and Protocol B." ,
1476- "selected_early_actions" : "The early actions selected." ,
1477- "overall_objective_intervention" : "To reduce risks through early actions." ,
1478- "eap_registration" : third_snapshot .eap_registration_id ,
1479- "updated_checklist_file" : tmp_file ,
1480- }
1481-
1482- response = self .client .patch (url , file_data , format = "multipart" )
1483- self .assertEqual (response .status_code , 200 )
1485+ response = self .client .patch (url , file_data , format = "json" )
1486+ self .assertEqual (response .status_code , 200 )
14841487
14851488 # SUCCESS:
14861489 self .authenticate (self .country_admin )
0 commit comments