Skip to content

Flaky/broken test: test_continue_task_without_target_date_uses_next_working_day (NameError: day_service) #3

Description

@colindickson

Summary

backend/tests/test_tasks.py::test_continue_task_without_target_date_uses_next_working_day fails with a NameError.

This is pre-existing and unrelated to the sub-goals feature — surfaced while running the full backend suite during sub-goals work. The rest of the suite passes (286 passed, this 1 failed).

Failure

tests/test_tasks.py:885: NameError
    monday = date(2025, 6, 9)
>   target_day = await day_service.get_or_create_by_date(monday)
E   NameError: name 'day_service' is not defined

Root cause

The test body references a local day_service that is never defined in this test function. It appears to have been introduced in commit 3346b74 ("feat: merge continue-tomorrow and roll-forward into single continue action") when the test was rewritten from the old roll_forward flow to the new continue_task flow — the DayService instantiation was dropped.

Other tests in the same file (e.g. around test_tasks.py:500) construct it explicitly: day_service = DayService(db_session).

Suggested fix

Instantiate day_service = DayService(db_session) within the test before use (mirroring the sibling tests), or assert the new task's day_id against a freshly created day via the existing service.

Repro

docker compose exec -T backend pytest tests/test_tasks.py::test_continue_task_without_target_date_uses_next_working_day -q

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions