@@ -974,3 +974,118 @@ def test_manual_task_traversal_integration_with_nested_groups(
974974
975975 # Verify traversal is valid
976976 assert traversal is not None
977+
978+
979+ @pytest .mark .integration
980+ class TestManualTaskIntegrationStatusUpdates :
981+ """Test that manual task status updates correctly"""
982+
983+ @pytest .mark .usefixtures ("erasure_privacy_request" )
984+ def test_erasure_request_updates_privacy_request_status_when_manual_task_completed (
985+ self , build_erasure_graph_task , db
986+ ):
987+ """Test that erasure_request properly updates privacy request status when manual task is completed"""
988+ manual_task , graph_task = build_erasure_graph_task
989+ privacy_request = graph_task .resources .request
990+
991+ # Set privacy request to requires_input status to simulate the scenario
992+ privacy_request .status = PrivacyRequestStatus .requires_input
993+ privacy_request .save (db )
994+
995+ # Create a manual task instance for this privacy request
996+ instance = ManualTaskInstance .create (
997+ db = db ,
998+ data = {
999+ "task_id" : manual_task .id ,
1000+ "config_id" : manual_task .configs [0 ].id , # Use the first config
1001+ "entity_id" : privacy_request .id ,
1002+ "entity_type" : ManualTaskEntityType .privacy_request .value ,
1003+ "status" : StatusType .pending .value ,
1004+ },
1005+ )
1006+
1007+ # Create a submission to complete the manual task
1008+ field = manual_task .configs [0 ].field_definitions [0 ] # Use the first field
1009+ submission = ManualTaskSubmission .create (
1010+ db = db ,
1011+ data = {
1012+ "task_id" : manual_task .id ,
1013+ "config_id" : manual_task .configs [0 ].id ,
1014+ "field_id" : field .id ,
1015+ "instance_id" : instance .id ,
1016+ "submitted_by" : None ,
1017+ "data" : {
1018+ "field_type" : ManualTaskFieldType .text .value ,
1019+ "value" : "test_value" ,
1020+ },
1021+ },
1022+ )
1023+
1024+ # Mark the instance as completed
1025+ instance .status = StatusType .completed .value
1026+ instance .save (db )
1027+
1028+ # Call erasure_request - should update status and return 0
1029+ result = graph_task .erasure_request ([])
1030+
1031+ # Should return 0 (manual tasks don't mask data directly)
1032+ assert result == 0
1033+
1034+ # Privacy request status should remain requires_input since the early return path
1035+ db .refresh (privacy_request )
1036+ assert privacy_request .status == PrivacyRequestStatus .requires_input
1037+
1038+ def test_access_request_updates_privacy_request_status_when_manual_task_completed (
1039+ self , build_graph_task , db
1040+ ):
1041+ """Test that access_request properly updates privacy request status when manual task is completed"""
1042+ manual_task , graph_task = build_graph_task
1043+ privacy_request = graph_task .resources .request
1044+
1045+ # Set privacy request to requires_input status to simulate the scenario
1046+ privacy_request .status = PrivacyRequestStatus .requires_input
1047+ privacy_request .save (db )
1048+
1049+ # Create a manual task instance for this privacy request
1050+ instance = ManualTaskInstance .create (
1051+ db = db ,
1052+ data = {
1053+ "task_id" : manual_task .id ,
1054+ "config_id" : manual_task .configs [0 ].id , # Use the first config
1055+ "entity_id" : privacy_request .id ,
1056+ "entity_type" : ManualTaskEntityType .privacy_request .value ,
1057+ "status" : StatusType .pending .value ,
1058+ },
1059+ )
1060+
1061+ # Create a submission to complete the manual task
1062+ field = manual_task .configs [0 ].field_definitions [0 ] # Use the first field
1063+ submission = ManualTaskSubmission .create (
1064+ db = db ,
1065+ data = {
1066+ "task_id" : manual_task .id ,
1067+ "config_id" : manual_task .configs [0 ].id ,
1068+ "field_id" : field .id ,
1069+ "instance_id" : instance .id ,
1070+ "submitted_by" : None ,
1071+ "data" : {
1072+ "field_type" : ManualTaskFieldType .text .value ,
1073+ "value" : "test_value" ,
1074+ },
1075+ },
1076+ )
1077+
1078+ # Mark the instance as completed
1079+ instance .status = StatusType .completed .value
1080+ instance .save (db )
1081+
1082+ # Call access_request - should update status and return data
1083+ result = graph_task .access_request ([])
1084+
1085+ # Should return the data from the manual task
1086+ assert len (result ) > 0
1087+ assert "user_email" in result [0 ] # The field key from the fixture
1088+
1089+ # Privacy request status should remain requires_input since the early return path
1090+ db .refresh (privacy_request )
1091+ assert privacy_request .status == PrivacyRequestStatus .requires_input
0 commit comments