fix: restore utcnow() in test_detections.py#578
Conversation
…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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@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 Codecov subtracts these two and reports -1.65%, but they're not measuring the same thing. Path forwardI 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. |
Summary
Seven test functions in
src/tests/endpoints/test_detections.pystill calldatetime.utcnow(), but thedatetimeimport was removed in #574 when those call sites were missed during the cleanup. This breakspytest,pytest-client, andprecommit-hookson every PR againstmain.This PR restores the calls by using the already-imported
utcnow()helper fromapp.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 checkclean