Skip to content

fix: restore utcnow() in test_detections.py#578

Merged
MateoLostanlen merged 1 commit intomainfrom
alexis/fix-test-detections-utcnow
Apr 29, 2026
Merged

fix: restore utcnow() in test_detections.py#578
MateoLostanlen merged 1 commit intomainfrom
alexis/fix-test-detections-utcnow

Conversation

@Acruve15
Copy link
Copy Markdown
Collaborator

Summary

Seven test functions in src/tests/endpoints/test_detections.py still call datetime.utcnow(), but the datetime import was removed in #574 when those call sites were missed during the cleanup. This breaks pytest, pytest-client, and precommit-hooks on every PR against main.

This PR restores the calls by using the already-imported utcnow() helper from app.core.time (same fix that was applied elsewhere in #574).

Test plan

  • pytest tests/endpoints/test_detections.py -v (67 / 67 pass)
  • ruff 0.11.9 check clean

…n test_detections

Follow-up to #574. Seven test functions in test_detections.py still called
datetime.utcnow() after the datetime import was removed, breaking pytest
and pre-commit on every PR against main.
@Acruve15 Acruve15 self-assigned this Apr 28, 2026
@Acruve15 Acruve15 requested review from MateoLostanlen and fe51 April 28, 2026 11:49
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.75%. Comparing base (f86f703) to head (e66ae87).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #578      +/-   ##
==========================================
- Coverage   90.40%   88.75%   -1.65%     
==========================================
  Files           3       52      +49     
  Lines         125     2196    +2071     
==========================================
+ Hits          113     1949    +1836     
- Misses         12      247     +235     
Flag Coverage Δ
backend 88.65% <ø> (?)
client 90.40% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

@Acruve15
Copy link
Copy Markdown
Collaborator Author

@fe51 @MateoLostanlen Heads up on the codecov check: the failure here is a measurement artifact, not a real coverage drop.

What's happening?

Our tests.yml workflow uploads coverage from two separate jobs (pytest for backend, pytest-client for client). Since #574 merged, the pytest job has been failing on main because of leftover datetime.utcnow() calls in test_detections.py. That means every push to main since then only uploaded the client flag (3 files).

Codecov's flag carryforward kept the old backend numbers around for a while, but the cache eventually expired. Today main's stored coverage is just the 3 client files.

Why this PR looks like a regression

main (base):  3 files,   125 lines, 90.40%   (client only)
this PR:     52 files, 2225 lines, 88.75%   (full backend + client)

Codecov subtracts these two and reports -1.65%, but they're not measuring the same thing.

Path forward

I split the datetime.utcnow() cleanup into #578 so it can land on its own. Once that merges, main's pytest job will be green again and the next push to main will upload a complete backend report. Codecov's base will then match this PR's scope and the project check should pass automatically (no force-push needed on this PR).

#578 itself will also fail codecov/project for the same reason. It would need a one-time admin override to merge. After that the system is self-healing and we don't need a codecov.yml workaround.

Copy link
Copy Markdown
Member

@MateoLostanlen MateoLostanlen left a comment

Choose a reason for hiding this comment

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

Good catch thanks

@MateoLostanlen MateoLostanlen merged commit 1f67522 into main Apr 29, 2026
23 of 24 checks passed
@MateoLostanlen MateoLostanlen deleted the alexis/fix-test-detections-utcnow branch April 29, 2026 10:20
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