Skip to content

test(evaluations): keep the review API cases inside the 90-day window - #322

Merged
TNT-Likely merged 1 commit into
TNT-Likely:mainfrom
Hansen1018:fix/evaluations-test-window
Dec 2, 2026
Merged

TNT-Likely merged 1 commit into
TNT-Likely:mainfrom
Hansen1018:fix/evaluations-test-window

Conversation

@Hansen1018

Copy link
Copy Markdown
Contributor

Replaces #316, which was closed on 2026-12-01 after its branch had been deleted; the fix itself is unchanged and is now rebased onto the current main.

Background

The release workflow runs python -m pytest tests/ -x -q before it builds the Docker image, and that gate started failing on 2026-11-27.

tests/test_evaluations_api.py built its fixture with a hard-coded prediction_date="2026-08-28", while the review API only returns rows inside a rolling window (prediction_date >= today - days, days defaults to 90). The fixture was inside that window on the day it was written and fell out of it on 2026-11-27, so three cases started failing and every release build stopped at the test step.

Observed in the release run of this repository (release / Run tests):

FAILED tests/test_evaluations_api.py::test_list_agent_predictions_returns_one_group_with_policy - assert 0 == 1
1 failed, 446 passed, 1 skipped, 13 warnings in 28.30s

The same three cases also fail the upstream Application regression / backend job on every pull request, including ones that do not touch this area:

FAILED tests/test_evaluations_api.py::test_list_agent_predictions_returns_one_group_with_policy - assert 0 == 1
FAILED tests/test_evaluations_api.py::test_summary_only_counts_trading_day_records - KeyError: '5'
FAILED tests/test_evaluations_api.py::test_status_filter_keeps_all_horizons_for_matched_suggestion - assert 0 == 1
3 failed, 1505 passed, 3 skipped, 33 warnings in 109.40s (0:01:49)

Changes

  • tests/test_evaluations_api.py only: the fixture date is now computed relative to today (date.today() - timedelta(days=10)) instead of being pinned to a calendar date. The legacy calendar-day record uses the same relative date, so it stays inside the window and is still excluded from the hit-rate summary by horizon_unit, not by its date.

No production code is touched.

Scope

One outcome: the review API test cases no longer expire, so the release test gate stays green.

Excluded: no change to the review API, its window semantics or any other test.

Validation

Tested commit: 6316168

Commands and results:

$ .venv/bin/python -m pytest -q tests/test_evaluations_api.py
4 passed, 12 warnings in 4.27s

$ .venv/bin/python -m pytest -q
1506 passed, 3 skipped, 33 warnings in 181.35s (0:03:01)

Before the change the same file reported 3 failed, 1 passed because the hard-coded date fell out of the 90-day window, and the whole suite reported 3 failed, 1505 passed.

Acceptance evidence

Steps:

  1. Check out this commit and run .venv/bin/python -m pytest -q tests/test_evaluations_api.py.
  2. Or move the clock forward, for example with faketime, and run the same command again.

Expected:

  • The four review API cases pass on any calendar day.
  • The cases still assert the 90-day window behaviour: a record older than the window stays excluded.

Observed:

$ .venv/bin/python -m pytest -q tests/test_evaluations_api.py
4 passed, 12 warnings in 5.52s

Evidence: the same file, and the release workflow run that exposed the failure (quoted in the Background section). The fixture date is derived from date.today(), so the cases cannot expire again.

Boundaries and risks

  • The change is confined to a test file; no product behaviour, API contract or schema is affected.
  • The fixture now sits 10 days before today instead of on a fixed date. The cases never assert an absolute date, so the relative date keeps their meaning.
  • The release workflow and the upstream main branch have been failing on this test since 2026-11-27, independently of this pull request.

Follow-up

None.

The review API fixtures used a hard-coded prediction_date of 2026-08-28
while the API only returns rows from the last 90 days, so the cases
started failing on 2026-11-27 and broke the release workflow test gate.

Use a date relative to today instead: the cases keep asserting the same
window behaviour and no longer expire.
@Hansen1018

Copy link
Copy Markdown
Contributor Author

Continuing #316, which was closed on 2026-12-01 after its branch had been deleted — GitHub refuses to reopen a pull request whose head branch is gone, so the same fix is submitted again from a clean branch.

What is in this pull request:

Why it matters right now: the review API only returns rows from the last 90 days, so the pinned fixture fell out of the window on 2026-11-27 and the three cases have failed on main and on every pull request since — the Application regression / backend job is red for all of them:

FAILED tests/test_evaluations_api.py::test_list_agent_predictions_returns_one_group_with_policy - assert 0 == 1
FAILED tests/test_evaluations_api.py::test_summary_only_counts_trading_day_records - KeyError: '5'
FAILED tests/test_evaluations_api.py::test_status_filter_keeps_all_horizons_for_matched_suggestion - assert 0 == 1
3 failed, 1505 passed, 3 skipped, 33 warnings in 109.40s (0:01:49)

With this change the suite is green again:

$ .venv/bin/python -m pytest -q tests/test_evaluations_api.py
4 passed, 12 warnings in 4.27s

$ .venv/bin/python -m pytest -q
1506 passed, 3 skipped, 33 warnings in 181.35s (0:03:01)

The cases still assert the same window behaviour — a record inside the window is returned, a record outside it is not — they just no longer expire with the calendar. The release workflow (release / Run tests) and the pull-request backend job both depend on this gate, so merging this restores the green build for #318 and #319 as well.

If a different approach is preferred for this (for example freezing the clock instead of deriving the date), please say so and I will rework it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants