feat(briefing): add task change detection helpers and task_id to _gather_internal
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,42 @@ def test_slot_greeting():
|
||||
assert slot_greeting("midday") != slot_greeting("afternoon")
|
||||
|
||||
|
||||
def test_compute_task_snapshot_hash():
|
||||
"""compute_task_hash should return a stable SHA-256 hex string."""
|
||||
from fabledassistant.services.briefing_pipeline import compute_task_hash
|
||||
|
||||
task = {"status": "todo", "priority": "high", "due_date": "2026-03-25", "title": "Write spec"}
|
||||
h = compute_task_hash(task)
|
||||
assert len(h) == 64 # SHA-256 hex
|
||||
assert h == compute_task_hash(task)
|
||||
assert h != compute_task_hash({**task, "status": "done"})
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_split_changed_tasks_all_new():
|
||||
"""split_changed_tasks should return all tasks as changed when no snapshot exists."""
|
||||
from fabledassistant.services.briefing_pipeline import split_changed_tasks
|
||||
|
||||
tasks = [
|
||||
{"task_id": 1, "title": "A", "status": "todo", "priority": "none", "due_date": None},
|
||||
]
|
||||
|
||||
with patch(
|
||||
"fabledassistant.services.briefing_pipeline.async_session"
|
||||
) as mock_cls:
|
||||
mock_session = AsyncMock()
|
||||
mock_session.__aenter__ = AsyncMock(return_value=mock_session)
|
||||
mock_session.__aexit__ = AsyncMock(return_value=False)
|
||||
mock_session.execute = AsyncMock(return_value=MagicMock(
|
||||
scalars=MagicMock(return_value=MagicMock(all=MagicMock(return_value=[])))
|
||||
))
|
||||
mock_cls.return_value = mock_session
|
||||
|
||||
changed, unchanged_count = await split_changed_tasks(user_id=1, tasks=tasks)
|
||||
assert len(changed) == 1
|
||||
assert unchanged_count == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_post_message_accepts_metadata():
|
||||
"""post_message should accept an optional metadata dict and store it."""
|
||||
|
||||
Reference in New Issue
Block a user