summaryrefslogtreecommitdiff
path: root/servers/taskwarrior/tests/test_server.py
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-12-19 17:12:10 +0100
committerDawid Rycerz <dawid@rycerz.xyz>2025-12-19 17:12:10 +0100
commitbedbd86e8c70d8d8cfa964842e1eab314384271d (patch)
treed7aec04e6c64012774477c39bd0d91c1bcc3d4ed /servers/taskwarrior/tests/test_server.py
parent195fb4507405648faf8a5729610457c24aa82430 (diff)
feat: enhance task completion functionality in TaskWarrior server
- Updated `done_task` method to accept a list of UUIDs for marking multiple tasks as completed. - Adjusted related tests to validate single and multiple task completion, including error handling for empty UUID lists. - Improved docstrings for clarity and consistency.
Diffstat (limited to 'servers/taskwarrior/tests/test_server.py')
-rw-r--r--servers/taskwarrior/tests/test_server.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/servers/taskwarrior/tests/test_server.py b/servers/taskwarrior/tests/test_server.py
index f96f817..97f7268 100644
--- a/servers/taskwarrior/tests/test_server.py
+++ b/servers/taskwarrior/tests/test_server.py
@@ -120,7 +120,7 @@ class TestTaskWarriorServer:
@pytest.mark.asyncio
async def test_done_task(self, taskwarrior_server):
- """Test marking a task as done."""
+ """Test marking a single task as done."""
mock_output = "Completed task test-uuid-123."
with patch.object(
@@ -128,9 +128,32 @@ class TestTaskWarriorServer:
new_callable=AsyncMock,
return_value=(mock_output, '', 0)
):
- result = await taskwarrior_server.done_task("test-uuid-123")
- assert result["uuid"] == "test-uuid-123"
+ result = await taskwarrior_server.done_task(["test-uuid-123"])
+ assert result["uuids"] == ["test-uuid-123"]
+ assert result["status"] == "completed"
+
+ @pytest.mark.asyncio
+ async def test_done_task_multiple(self, taskwarrior_server):
+ """Test marking multiple tasks as done."""
+ mock_output = "Completed task test-uuid-123.\nCompleted task test-uuid-456."
+
+ with patch.object(
+ taskwarrior_server, '_run_task_command',
+ new_callable=AsyncMock,
+ return_value=(mock_output, '', 0)
+ ):
+ result = await taskwarrior_server.done_task(["test-uuid-123", "test-uuid-456"])
+ assert result["uuids"] == ["test-uuid-123", "test-uuid-456"]
assert result["status"] == "completed"
+ assert len(result["uuids"]) == 2
+
+ @pytest.mark.asyncio
+ async def test_done_task_empty_list(self, taskwarrior_server):
+ """Test that marking tasks with empty list raises ValueError."""
+ with pytest.raises(ValueError) as exc_info:
+ await taskwarrior_server.done_task([])
+
+ assert "At least one UUID is required" in str(exc_info.value)
@pytest.mark.asyncio
async def test_delete_task(self, taskwarrior_server):