feat: annuleren taak toegevoegd
This commit is contained in:
@@ -109,6 +109,38 @@ class TaskRecoveryServiceTest(unittest.TestCase):
|
||||
self.assertEqual(task["status"], "failed")
|
||||
self.assertEqual(task["error_code"], "task_interrupted")
|
||||
|
||||
def test_reconcile_persisted_incomplete_tasks_marks_stale_cancelling_task_failed(self) -> None:
|
||||
self.task_repo.insert_task_for_testing(
|
||||
{
|
||||
"id": "task-cancelling",
|
||||
"operation": "duplicate",
|
||||
"status": "cancelling",
|
||||
"source": "2 items",
|
||||
"destination": "same directory",
|
||||
"created_at": "2026-03-10T10:00:00Z",
|
||||
"started_at": "2026-03-10T10:00:01Z",
|
||||
"current_item": "storage1/report.txt",
|
||||
}
|
||||
)
|
||||
self.history_repo.create_entry(
|
||||
entry_id="task-cancelling",
|
||||
operation="duplicate",
|
||||
status="queued",
|
||||
source="2 items",
|
||||
destination="same directory",
|
||||
created_at="2026-03-10T10:00:00Z",
|
||||
)
|
||||
|
||||
changed = reconcile_persisted_incomplete_tasks(self.task_repo, self.history_repo)
|
||||
|
||||
self.assertEqual(changed, ["task-cancelling"])
|
||||
task = self.task_repo.get_task("task-cancelling")
|
||||
self.assertEqual(task["status"], "failed")
|
||||
self.assertEqual(task["error_code"], "task_interrupted")
|
||||
history = self.history_repo.list_history(limit=5)[0]
|
||||
self.assertEqual(history["id"], "task-cancelling")
|
||||
self.assertEqual(history["status"], "failed")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user