Skip to content

test(risk-filter): seed date-based tests away from midnight UTC - #742

Merged
MateoLostanlen merged 1 commit into
pyronear:mainfrom
Majyles:fix/risk-filter-midnight-tests
Nov 18, 2026
Merged

MateoLostanlen merged 1 commit into
pyronear:mainfrom
Majyles:fix/risk-filter-midnight-tests

Conversation

@Majyles

@Majyles Majyles commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Closes #738

Four tests in test_risk_filter.py query endpoints that return a single UTC day (date(started_at) == from_date), but seeded their data 20 to 50 minutes before now and asked for today. Shortly after midnight UTC the seeds fell on the previous day.

  • The two seeding helpers take an optional reference time (default: now, so the other tests are unchanged).
  • The four date-based tests seed relative to noon UTC yesterday and use that date as from_date.
  • The two "drops the alert" tests were passing for the wrong reason after midnight (the alert was absent because of the date, not the filter); they now exercise the filter at any hour.

The other tests in the file target the /unlabeled/latest endpoints, which use a sliding 24 h window and are not affected.

Checked by faking the test clock to 00:10 UTC: 6 failures before the change, 30/30 passing after. Full suite passes.

Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Majyles

Majyles commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

The pytest-client failure is the known flaky test_client_constructor (read-timeout case), fixed by #740; this PR only touches src/tests/endpoints/test_risk_filter.py, and the pytest job is green.

@MateoLostanlen MateoLostanlen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Majyles, thanks for the PR!

Clean fix. Anchoring the seeds at noon yesterday makes these tests independent of the hour, and the "drops the alert" cases now actually test the filter.

I checked it with the clock faked to 00:10 UTC: the old version fails, this one passes.

The pytest-client failure is the flaky test fixed in #740. I'll merge that one first, then re-run CI here and merge.

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.33%. Comparing base (8167f1c) to head (2206952).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #742   +/-   ##
=======================================
  Coverage   95.33%   95.33%           
=======================================
  Files          61       61           
  Lines        3428     3428           
=======================================
  Hits         3268     3268           
  Misses        160      160           
Flag Coverage Δ
backend 95.48% <ø> (ø)
client 91.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MateoLostanlen MateoLostanlen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Majyles, thanks for the PR!

Clean and well-scoped fix. I reproduced it locally with the clock faked to 00:10 UTC: 6 failures on main, 30/30 with this branch.

Happy to merge, thanks!

@MateoLostanlen
MateoLostanlen merged commit ba56d3c into pyronear:main Nov 18, 2026
24 of 25 checks passed
@Majyles
Majyles deleted the fix/risk-filter-midnight-tests branch November 19, 2026 16:31
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.

Tests in test_risk_filter.py fail when CI runs shortly after midnight UTC

2 participants