30 lines
959 B
Python
30 lines
959 B
Python
from agent_todos.models import Priority, Status, Todo
|
|
from agent_todos.store import Store
|
|
|
|
|
|
def _store(tmp_path, name="test.db") -> tuple[Store, str]:
|
|
p = str(tmp_path / name)
|
|
return Store(db_path=p), p
|
|
|
|
|
|
def test_create_and_list(tmp_path):
|
|
store, _ = _store(tmp_path)
|
|
todo = store.create(Todo(id=None, title="Test task", repo="org/repo", priority=Priority.high))
|
|
assert todo.id is not None
|
|
all_todos = store.list()
|
|
assert any(t.id == todo.id for t in all_todos)
|
|
|
|
|
|
def test_update_status(tmp_path):
|
|
store, _ = _store(tmp_path)
|
|
todo = store.create(Todo(id=None, title="Test task"))
|
|
updated = store.update(todo.id, status=Status.in_progress)
|
|
assert updated.status == Status.in_progress
|
|
|
|
|
|
def test_close_resolves(tmp_path):
|
|
store, _ = _store(tmp_path)
|
|
todo = store.create(Todo(id=None, title="Test task"))
|
|
store.update(todo.id, status=Status.resolved)
|
|
assert store.get(todo.id).resolved_at is not None
|