@@ -386,10 +386,10 @@ def test_mapping_lock_returns_403_for_if_user_not_allowed_to_map(
386
386
)
387
387
388
388
@patch .object (ProjectAdminService , "is_user_action_permitted_on_project" )
389
- def test_mapping_lock_returns_403_if_task_in_invalid_state_for_mapping (
389
+ def test_mapping_lock_returns_409_if_task_in_invalid_state_for_mapping (
390
390
self , mock_pm_role
391
391
):
392
- """Test returns 403 if task is in invalid state for mapping. i.e. not in READY or INVALIDATED state."""
392
+ """Test returns 409 if task is in invalid state for mapping. i.e. not in READY or INVALIDATED state."""
393
393
# Arrange
394
394
mock_pm_role .return_value = True
395
395
# Act
@@ -398,7 +398,7 @@ def test_mapping_lock_returns_403_if_task_in_invalid_state_for_mapping(
398
398
)
399
399
# Assert
400
400
# As Task 1 is in MAPPED state, it should not be allowed to be locked for mapping.
401
- self .assertEqual (response .status_code , 403 )
401
+ self .assertEqual (response .status_code , 409 )
402
402
self .assertEqual (response .json ["SubCode" ], "InvalidTaskState" )
403
403
404
404
# Arrange
@@ -411,7 +411,7 @@ def test_mapping_lock_returns_403_if_task_in_invalid_state_for_mapping(
411
411
)
412
412
# Assert
413
413
# As Task 1 is in VALIDATED state, it should not be allowed to be locked for mapping.
414
- self .assertEqual (response .status_code , 403 )
414
+ self .assertEqual (response .status_code , 409 )
415
415
self .assertEqual (response .json ["SubCode" ], "InvalidTaskState" )
416
416
417
417
@patch .object (UserService , "has_user_accepted_license" )
@@ -513,20 +513,20 @@ def test_mapping_unlock_returns_404_for_invalid_task_id(self):
513
513
self .assertEqual (response .status_code , 404 )
514
514
self .assertEqual (response .json ["error" ]["sub_code" ], TASK_NOT_FOUND_SUB_CODE )
515
515
516
- def test_mapping_unlock_returns_403_if_task_not_locked_for_mapping (self ):
517
- """Test returns 403 if task is not locked for mapping."""
516
+ def test_mapping_unlock_returns_409_if_task_not_locked_for_mapping (self ):
517
+ """Test returns 409 if task is not locked for mapping."""
518
518
# Act
519
519
response = self .client .post (
520
520
self .url ,
521
521
headers = {"Authorization" : self .user_session_token },
522
522
json = {"status" : "MAPPED" },
523
523
)
524
524
# Assert
525
- self .assertEqual (response .status_code , 403 )
525
+ self .assertEqual (response .status_code , 409 )
526
526
self .assertEqual (response .json ["SubCode" ], "LockBeforeUnlocking" )
527
527
528
- def test_mapping_unlock_returns_403_if_task_locked_by_other_user (self ):
529
- """Test returns 403 if task is locked by other user."""
528
+ def test_mapping_unlock_returns_409_if_task_locked_by_other_user (self ):
529
+ """Test returns 409 if task is locked by other user."""
530
530
# Arrange
531
531
task = Task .get (1 , self .test_project .id )
532
532
task .task_status = TaskStatus .LOCKED_FOR_MAPPING .value
@@ -539,11 +539,11 @@ def test_mapping_unlock_returns_403_if_task_locked_by_other_user(self):
539
539
json = {"status" : "MAPPED" },
540
540
)
541
541
# Assert
542
- self .assertEqual (response .status_code , 403 )
542
+ self .assertEqual (response .status_code , 409 )
543
543
self .assertEqual (response .json ["SubCode" ], "TaskNotOwned" )
544
544
545
- def test_returns_403_if_invalid_new_state_passed (self ):
546
- """Test returns 403 if invalid new state passed as new task state should be READY, MAPPED or BADIMAGERY."""
545
+ def test_returns_409_if_invalid_new_state_passed (self ):
546
+ """Test returns 409 if invalid new state passed as new task state should be READY, MAPPED or BADIMAGERY."""
547
547
# Arrange
548
548
task = Task .get (1 , self .test_project .id )
549
549
task .task_status = TaskStatus .LOCKED_FOR_MAPPING .value
@@ -556,7 +556,7 @@ def test_returns_403_if_invalid_new_state_passed(self):
556
556
json = {"status" : "INVALIDATED" },
557
557
)
558
558
# Assert
559
- self .assertEqual (response .status_code , 403 )
559
+ self .assertEqual (response .status_code , 409 )
560
560
self .assertEqual (response .json ["SubCode" ], "InvalidUnlockState" )
561
561
562
562
def test_mapping_unlock_returns_200_on_success (self ):
@@ -664,11 +664,11 @@ def test_mapping_stop_returns_403_if_task_not_locked_for_mapping(self):
664
664
headers = {"Authorization" : self .user_session_token },
665
665
)
666
666
# Assert
667
- self .assertEqual (response .status_code , 403 )
667
+ self .assertEqual (response .status_code , 409 )
668
668
self .assertEqual (response .json ["SubCode" ], "LockBeforeUnlocking" )
669
669
670
- def test_mapping_stop_returns_403_if_task_locked_by_other_user (self ):
671
- """Test returns 403 if task locked by other user."""
670
+ def test_mapping_stop_returns_409_if_task_locked_by_other_user (self ):
671
+ """Test returns 409 if task locked by other user."""
672
672
# Arrange
673
673
task = Task .get (1 , self .test_project .id )
674
674
task .task_status = TaskStatus .LOCKED_FOR_MAPPING .value
@@ -680,7 +680,7 @@ def test_mapping_stop_returns_403_if_task_locked_by_other_user(self):
680
680
headers = {"Authorization" : self .user_session_token },
681
681
)
682
682
# Assert
683
- self .assertEqual (response .status_code , 403 )
683
+ self .assertEqual (response .status_code , 409 )
684
684
self .assertEqual (response .json ["SubCode" ], "TaskNotOwned" )
685
685
686
686
def test_mapping_stop_returns_200_on_success (self ):
@@ -780,8 +780,8 @@ def test_validation_lock_returns_404_for_invalid_task_id(self):
780
780
self .assertEqual (response .status_code , 404 )
781
781
self .assertEqual (response .json ["error" ]["sub_code" ], TASK_NOT_FOUND_SUB_CODE )
782
782
783
- def test_validation_lock_returns_403_if_task_not_ready_for_validation (self ):
784
- """Test returns 403 if task not ready for validation."""
783
+ def test_validation_lock_returns_409_if_task_not_ready_for_validation (self ):
784
+ """Test returns 409 if task not ready for validation."""
785
785
# Arrange
786
786
task = Task .get (1 , self .test_project .id )
787
787
task .task_status = TaskStatus .READY .value # not ready for validation
@@ -793,13 +793,13 @@ def test_validation_lock_returns_403_if_task_not_ready_for_validation(self):
793
793
json = {"taskIds" : [1 ]},
794
794
)
795
795
# Assert
796
- self .assertEqual (response .status_code , 403 )
796
+ self .assertEqual (response .status_code , 409 )
797
797
self .assertEqual (response .json ["SubCode" ], "NotReadyForValidation" )
798
798
799
- def test_validation_lock_returns_403_if_mapped_by_same_user_and_user_not_admin (
799
+ def test_validation_lock_returns_409_if_mapped_by_same_user_and_user_not_admin (
800
800
self ,
801
801
):
802
- """Test returns 403 if mapped by same user."""
802
+ """Test returns 409 if mapped by same user."""
803
803
# Arrange
804
804
task = Task .get (1 , self .test_project .id )
805
805
task .task_status = TaskStatus .MAPPED .value
@@ -812,7 +812,7 @@ def test_validation_lock_returns_403_if_mapped_by_same_user_and_user_not_admin(
812
812
json = {"taskIds" : [1 ]},
813
813
)
814
814
# Assert
815
- self .assertEqual (response .status_code , 403 )
815
+ self .assertEqual (response .status_code , 409 )
816
816
self .assertEqual (response .json ["SubCode" ], "CannotValidateMappedTask" )
817
817
818
818
def test_validation_lock_returns_403_if_user_not_permitted_to_validate (self ):
@@ -871,10 +871,10 @@ def test_validation_lock_returns_403_if_user_not_on_allowed_list(
871
871
)
872
872
# Assert
873
873
self .assertEqual (response .status_code , 403 )
874
- self .assertEqual (response .json ["SubCode" ] , "UserNotAllowed " )
874
+ self .assertEqual (response .json ["error" ][ "sub_code" ] , "USER_BLOCKED " )
875
875
876
- def test_validation_lock_returns_403_if_user_has_already_locked_other_task (self ):
877
- """Test returns 403 if user has already locked other task."""
876
+ def test_validation_lock_returns_409_if_user_has_already_locked_other_task (self ):
877
+ """Test returns 409 if user has already locked other task."""
878
878
# Arrange
879
879
self .test_project .status = ProjectStatus .PUBLISHED .value
880
880
self .test_project .save ()
@@ -889,7 +889,7 @@ def test_validation_lock_returns_403_if_user_has_already_locked_other_task(self)
889
889
json = {"taskIds" : [1 ]},
890
890
)
891
891
# Assert
892
- self .assertEqual (response .status_code , 403 )
892
+ self .assertEqual (response .status_code , 409 )
893
893
self .assertEqual (response .json ["SubCode" ], "UserAlreadyHasTaskLocked" )
894
894
895
895
@patch .object (ProjectService , "is_user_permitted_to_validate" )
@@ -980,16 +980,16 @@ def test_validation_unlock_returns_404_if_task_not_found(self):
980
980
self .assertEqual (response .status_code , 404 )
981
981
self .assertEqual (response .json ["error" ]["sub_code" ], TASK_NOT_FOUND_SUB_CODE )
982
982
983
- def test_validation_unlock_returns_403_if_task_not_locked_for_validation (self ):
984
- """Test returns 403 if task not locked for validation."""
983
+ def test_validation_unlock_returns_409_if_task_not_locked_for_validation (self ):
984
+ """Test returns 409 if task not locked for validation."""
985
985
# Act
986
986
response = self .client .post (
987
987
self .url ,
988
988
headers = {"Authorization" : self .user_session_token },
989
989
json = {"validatedTasks" : [{"taskId" : 1 , "status" : "VALIDATED" }]},
990
990
)
991
991
# Assert
992
- self .assertEqual (response .status_code , 403 )
992
+ self .assertEqual (response .status_code , 409 )
993
993
self .assertEqual (response .json ["SubCode" ], "NotLockedForValidation" )
994
994
995
995
@staticmethod
@@ -1002,8 +1002,8 @@ def lock_task_for_validation(task_id, project_id, user_id, mapped_by=None):
1002
1002
task .mapped_by = mapped_by
1003
1003
task .update ()
1004
1004
1005
- def test_validation_unlock_returns_403_if_task_locked_by_other_user (self ):
1006
- """Test returns 403 if task locked by other user."""
1005
+ def test_validation_unlock_returns_409_if_task_locked_by_other_user (self ):
1006
+ """Test returns 409 if task locked by other user."""
1007
1007
# Arrange
1008
1008
TestTasksActionsValidationUnlockAPI .lock_task_for_validation (
1009
1009
1 , self .test_project .id , self .test_author .id
@@ -1015,7 +1015,7 @@ def test_validation_unlock_returns_403_if_task_locked_by_other_user(self):
1015
1015
json = {"validatedTasks" : [{"taskId" : 1 , "status" : "VALIDATED" }]},
1016
1016
)
1017
1017
# Assert
1018
- self .assertEqual (response .status_code , 403 )
1018
+ self .assertEqual (response .status_code , 409 )
1019
1019
self .assertEqual (response .json ["SubCode" ], "TaskNotOwned" )
1020
1020
1021
1021
def test_validation_unlock_returns_400_if_invalid_state_passsed (self ):
@@ -1164,8 +1164,8 @@ def test_validation_stop_returns_404_if_task_not_found(self):
1164
1164
self .assertEqual (response .status_code , 404 )
1165
1165
self .assertEqual (response .json ["error" ]["sub_code" ], TASK_NOT_FOUND_SUB_CODE )
1166
1166
1167
- def test_validation_stop_returns_403_if_task_not_locked_for_validation (self ):
1168
- """Test returns 403 if task not locked for validation."""
1167
+ def test_validation_stop_returns_409_if_task_not_locked_for_validation (self ):
1168
+ """Test returns 409 if task not locked for validation."""
1169
1169
# Arrange
1170
1170
TestTasksActionsValidationUnlockAPI .lock_task_for_validation (
1171
1171
1 , self .test_project .id , self .test_user .id
@@ -1178,11 +1178,11 @@ def test_validation_stop_returns_403_if_task_not_locked_for_validation(self):
1178
1178
)
1179
1179
# Assert
1180
1180
# Since task 2 is not locked for validation, we should get a 403 even though task 1 is locked for validation
1181
- self .assertEqual (response .status_code , 403 )
1181
+ self .assertEqual (response .status_code , 409 )
1182
1182
self .assertEqual (response .json ["SubCode" ], "NotLockedForValidation" )
1183
1183
1184
- def test_validation_stop_returns_403_if_task_locked_by_other_user (self ):
1185
- """Test returns 403 if task locked by other user."""
1184
+ def test_validation_stop_returns_409_if_task_locked_by_other_user (self ):
1185
+ """Test returns 409 if task locked by other user."""
1186
1186
# Arrange
1187
1187
TestTasksActionsValidationUnlockAPI .lock_task_for_validation (
1188
1188
1 , self .test_project .id , self .test_author .id , self .test_author .id
@@ -1194,7 +1194,7 @@ def test_validation_stop_returns_403_if_task_locked_by_other_user(self):
1194
1194
json = {"resetTasks" : [{"taskId" : 1 }]},
1195
1195
)
1196
1196
# Assert
1197
- self .assertEqual (response .status_code , 403 )
1197
+ self .assertEqual (response .status_code , 409 )
1198
1198
self .assertEqual (response .json ["SubCode" ], "TaskNotOwned" )
1199
1199
1200
1200
def test_validation_stop_returns_200_if_task_locked_by_user (self ):
@@ -1287,8 +1287,8 @@ def test_returns_404_if_task_not_found(self):
1287
1287
self .assertEqual (response .status_code , 404 )
1288
1288
self .assertEqual (response .json ["error" ]["sub_code" ], TASK_NOT_FOUND_SUB_CODE )
1289
1289
1290
- def test_returns_403_if_task_too_small_to_split (self ):
1291
- """Test returns 403 if task too small to split."""
1290
+ def test_returns_409_if_task_too_small_to_split (self ):
1291
+ """Test returns 409 if task too small to split."""
1292
1292
# Arrange
1293
1293
task = Task .get (1 , self .test_project .id )
1294
1294
task .zoom = 18
@@ -1299,21 +1299,21 @@ def test_returns_403_if_task_too_small_to_split(self):
1299
1299
headers = {"Authorization" : self .author_session_token },
1300
1300
)
1301
1301
# Assert
1302
- self .assertEqual (response .status_code , 403 )
1302
+ self .assertEqual (response .status_code , 409 )
1303
1303
self .assertEqual (response .json ["SubCode" ], "SmallToSplit" )
1304
1304
1305
- def test_returns_403_if_task_not_locked_for_mapping (self ):
1306
- """Test returns 403 if task not locked for mapping."""
1305
+ def test_returns_409_if_task_not_locked_for_mapping (self ):
1306
+ """Test returns 409 if task not locked for mapping."""
1307
1307
# Since task should be locked for mapping to split, we should get a 403
1308
1308
response = self .client .post (
1309
1309
self .url ,
1310
1310
headers = {"Authorization" : self .author_session_token },
1311
1311
)
1312
- self .assertEqual (response .status_code , 403 )
1312
+ self .assertEqual (response .status_code , 409 )
1313
1313
self .assertEqual (response .json ["SubCode" ], "LockToSplit" )
1314
1314
1315
- def test_returns_403_if_task_locked_by_other_user (self ):
1316
- """Test returns 403 if task locked by other user."""
1315
+ def test_returns_409_if_task_locked_by_other_user (self ):
1316
+ """Test returns 409 if task locked by other user."""
1317
1317
# Arrange
1318
1318
test_user = return_canned_user ("test user" , 1111111 )
1319
1319
test_user .create ()
@@ -1325,7 +1325,7 @@ def test_returns_403_if_task_locked_by_other_user(self):
1325
1325
headers = {"Authorization" : self .author_session_token },
1326
1326
)
1327
1327
# Assert
1328
- self .assertEqual (response .status_code , 403 )
1328
+ self .assertEqual (response .status_code , 409 )
1329
1329
self .assertEqual (response .json ["SubCode" ], "SplitOtherUserTask" )
1330
1330
1331
1331
def test_returns_200_if_task_locked_by_user (self ):
@@ -1549,8 +1549,8 @@ def test_returns_404_if_task_not_found(self):
1549
1549
self .assertEqual (response .status_code , 404 )
1550
1550
self .assertEqual (response .json ["error" ]["sub_code" ], TASK_NOT_FOUND_SUB_CODE )
1551
1551
1552
- def test_returns_403_if_task_not_locked (self ):
1553
- """Test returns 403 if task not locked."""
1552
+ def test_returns_409_if_task_not_locked (self ):
1553
+ """Test returns 409 if task not locked."""
1554
1554
# Task should be locked for mapping or validation to extend
1555
1555
# Act
1556
1556
response = self .client .post (
@@ -1559,11 +1559,11 @@ def test_returns_403_if_task_not_locked(self):
1559
1559
json = {"taskIds" : [1 ]},
1560
1560
)
1561
1561
# Assert
1562
- self .assertEqual (response .status_code , 403 )
1562
+ self .assertEqual (response .status_code , 409 )
1563
1563
self .assertEqual (response .json ["SubCode" ], "TaskStatusNotLocked" )
1564
1564
1565
- def test_returns_403_if_task_is_not_locked_by_requesting_user (self ):
1566
- """Test returns 403 if task is not locked by requesting user."""
1565
+ def test_returns_409_if_task_is_not_locked_by_requesting_user (self ):
1566
+ """Test returns 409 if task is not locked by requesting user."""
1567
1567
# Task should be locked for mapping or validation to extend
1568
1568
# Arrange
1569
1569
task = Task .get (1 , self .test_project .id )
@@ -1575,7 +1575,7 @@ def test_returns_403_if_task_is_not_locked_by_requesting_user(self):
1575
1575
json = {"taskIds" : [1 ]},
1576
1576
)
1577
1577
# Assert
1578
- self .assertEqual (response .status_code , 403 )
1578
+ self .assertEqual (response .status_code , 409 )
1579
1579
self .assertEqual (response .json ["SubCode" ], "LockedByAnotherUser" )
1580
1580
1581
1581
def test_returns_200_if_task_locked_by_requesting_user (self ):
0 commit comments