From 5923b75982c7cf90661a13ebbc4b96512d732875 Mon Sep 17 00:00:00 2001 From: Illya Laifu Date: Wed, 1 Jan 2025 21:53:23 +0200 Subject: [PATCH 1/2] feat: remove Replica constructor in favor of staticmethods --- taskchampion.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/taskchampion.pyi b/taskchampion.pyi index f587d0d..c5c411e 100644 --- a/taskchampion.pyi +++ b/taskchampion.pyi @@ -3,7 +3,6 @@ from enum import Enum from typing import Optional, Iterator class Replica: - def __init__(self, path: str, create_if_missing: bool): ... @staticmethod def new_on_disk(path: str, create_if_missing: bool): ... @staticmethod From c52dcda7bd800203b4366c064a5c34dd893b81ad Mon Sep 17 00:00:00 2001 From: Illya Laifu Date: Wed, 1 Jan 2025 22:00:43 +0200 Subject: [PATCH 2/2] fix: add missing method in Task stub --- taskchampion.pyi | 1 + tests/test_task.py | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/taskchampion.pyi b/taskchampion.pyi index c5c411e..b0bb4f3 100644 --- a/taskchampion.pyi +++ b/taskchampion.pyi @@ -84,6 +84,7 @@ class Task: def get_entry(self) -> Optional[datetime]: ... def get_priority(self) -> str: ... def get_wait(self) -> Optional[datetime]: ... + def get_description(self) -> str: ... def is_waiting(self) -> bool: ... def is_active(self) -> bool: ... def is_blocked(self) -> bool: ... diff --git a/tests/test_task.py b/tests/test_task.py index 457b6f7..0c0579c 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -45,8 +45,6 @@ def blocked_task(): task = r.create_task(str(uuid.uuid4()), ops) r.commit_operations(ops) - # Fragile test, but I cannot mock Rust's Chrono, so this will do. - # Need to refresh the tag, the one that's in memory is stale return task @@ -57,7 +55,18 @@ def due_task(): task = r.create_task(str(uuid.uuid4()), ops) task.set_due(datetime.fromisoformat("2006-05-13T01:27:27+00:00"), ops) r.commit_operations(ops) - # Need to refresh the tag, the one that's in memory is stale + + return task + + +@pytest.fixture +def task_with_description(): + r = Replica.new_in_memory() + ops = Operations() + task = r.create_task(str(uuid.uuid4()), ops) + + task.set_description("This is a description", ops) + r.commit_operations(ops) return task @@ -124,3 +133,7 @@ def test_get_modified(waiting_task: Task): def test_get_due(due_task: Task): assert due_task.get_due() == datetime.fromisoformat("2006-05-13T01:27:27+00:00") + + +def test_get_description(task_with_description): + assert task_with_description.get_description() == "This is a description"