@@ -1274,6 +1274,8 @@ def test_status_transition(self):
12741274 response = self .client .post (self .url , data , format = "json" )
12751275 self .assertEqual (response .status_code , 200 , response .data )
12761276 self .assertEqual (response .data ["status" ], EAPStatus .UNDER_REVIEW )
1277+ simplified_eap .refresh_from_db ()
1278+ self .assertTrue (simplified_eap .is_locked )
12771279
12781280 # NOTE: Check if the NS can update after changing to UNDER_REVIEW
12791281 # FAILS: As simplified EAP is in UNDER_REVIEW, cannot update
@@ -1283,6 +1285,7 @@ def test_status_transition(self):
12831285 "readiness_budget" : 5000 ,
12841286 "pre_positioning_budget" : 5000 ,
12851287 "early_action_budget" : 5000 ,
1288+ "modified_at" : datetime .now (),
12861289 }
12871290 url = f"/api/v2/simplified-eap/{ simplified_eap .id } /"
12881291 response = self .client .patch (url , update_data , format = "json" )
@@ -1321,12 +1324,18 @@ def test_status_transition(self):
13211324 self .eap_registration .latest_simplified_eap .review_checklist_file ,
13221325 )
13231326
1327+ # Fails, As User only can revise after NS_ADDRESSING_COMMENTS, cannot update directly as it's locked
1328+ update_data ["modified_at" ] = datetime .now ()
1329+ response = self .client .patch (url , update_data , format = "json" )
1330+ self .assertEqual (response .status_code , 400 , response .data )
1331+
13241332 # NOTE: NS revise which creates a snapshot of simplified eap
13251333 # updates the latest simplified eap with updated checklist file. So, there should be two snapshots of SimplifiedEAP now.
13261334 revise_url = f"/api/v2/simplified-eap/{ simplified_eap .id } /revise/"
13271335 self .authenticate (self .country_admin )
13281336 response = self .client .post (revise_url )
1329- self .assertEqual (response .status_code , 200 )
1337+ self .assertEqual (response .status_code , 200 , response .data )
1338+ self .assertFalse (response .data ["is_locked" ], response .data )
13301339
13311340 # NOTE: Check if snapshot is created or not
13321341 # First SimplifedEAP should be locked
@@ -1371,13 +1380,21 @@ def test_status_transition(self):
13711380 self .eap_registration .latest_simplified_eap .id ,
13721381 second_snapshot .id ,
13731382 )
1383+ # Second snapshot should not be locked.
1384+ self .assertFalse (second_snapshot .is_locked , "Latest snapshot shouldn't be locked." ),
13741385
1375- # NOTE: Cannot create another snapshot from locked snapshot
1386+ # NOTE: Cannot create revise as this eap has already been revised once.
13761387 revise_url = f"/api/v2/simplified-eap/{ simplified_eap .id } /revise/"
13771388 self .authenticate (self .country_admin )
13781389 response = self .client .post (revise_url )
13791390 self .assertEqual (response .status_code , 400 , response .data )
13801391
1392+ # NOTE: Cannot update in previous snapshot
1393+ url = f"/api/v2/simplified-eap/{ simplified_eap .id } /"
1394+ update_data ["modified_at" ] = datetime .now ()
1395+ response = self .client .patch (url , update_data , format = "json" )
1396+ self .assertEqual (response .status_code , 400 , response .data )
1397+
13811398 # NOTE: Transition to UNDER_REVIEW
13821399 # NS_ADDRESSING_COMMENTS -> UNDER_REVIEW
13831400 data = {
@@ -1411,6 +1428,8 @@ def test_status_transition(self):
14111428 response = self .client .post (self .url , data , format = "json" )
14121429 self .assertEqual (response .status_code , 200 , response .data )
14131430 self .assertEqual (response .data ["status" ], EAPStatus .UNDER_REVIEW )
1431+ second_snapshot .refresh_from_db ()
1432+ self .assertTrue (second_snapshot .is_locked , "Should be locked after transition to UNDER_REVIEW." )
14141433
14151434 # AGAIN NOTE: Transition to NS_ADDRESSING_COMMENTS
14161435 # UNDER_REVIEW -> NS_ADDRESSING_COMMENTS
@@ -1433,10 +1452,16 @@ def test_status_transition(self):
14331452 self .assertEqual (response .status_code , 200 , response .data )
14341453 self .assertEqual (response .data ["status" ], EAPStatus .NS_ADDRESSING_COMMENTS )
14351454
1455+ # Cannot update as it is in NS_ADDRESSING_COMMENTS, only revise is allowed
1456+ update_data ["modified_at" ] = datetime .now ()
1457+ response = self .client .patch (url , update_data , format = "json" )
1458+ self .assertEqual (response .status_code , 400 , response .data )
1459+
14361460 revise_url = f"/api/v2/simplified-eap/{ second_snapshot .id } /revise/"
14371461 self .authenticate (self .country_admin )
14381462 response = self .client .post (revise_url )
1439- self .assertEqual (response .status_code , 200 )
1463+ self .assertEqual (response .status_code , 200 , response .data )
1464+ self .assertFalse (response .data ["is_locked" ])
14401465
14411466 # Check if three snapshots are created now
14421467 self .eap_registration .refresh_from_db ()
@@ -1482,12 +1507,18 @@ def test_status_transition(self):
14821507 third_snapshot .id ,
14831508 )
14841509
1485- # NOTE: Cannot create another snapshot from locked snapshot
1510+ # NOTE: Cannot create another snapshot as this eap has already been revised
14861511 revise_url = f"/api/v2/simplified-eap/{ second_snapshot .id } /revise/"
14871512 self .authenticate (self .country_admin )
14881513 response = self .client .post (revise_url )
14891514 self .assertEqual (response .status_code , 400 , response .data )
14901515
1516+ # NOTE: Cannot update the previous snapshot
1517+ url = f"/api/v2/simplified-eap/{ second_snapshot .id } /"
1518+ update_data ["modified_at" ] = datetime .now ()
1519+ response = self .client .patch (url , update_data , format = "json" )
1520+ self .assertEqual (response .status_code , 400 , response .data )
1521+
14911522 # NOTE: Again Transition to UNDER_REVIEW
14921523 # NS_ADDRESSING_COMMENTS -> UNDER_REVIEW
14931524 data = {
0 commit comments