Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix activeipcollector get_timestamp function implementation and its broken timezone-naive test #2831

Conversation

lunkwill42
Copy link
Member

Don't test epoch values against naive datetimes

When running the test suite on a machine set to the UTC timezone, test_find_timestamp would fail, because the datetime object used to seed the value is timezone-naive. The test would work fine in UTC+1 timezones, but not in other timezones.

This also refactors the convoluted logic of the function itself.

When running the test suite on a machine set to the UTC timezone,
`test_find_timestamp` would fail, because the datetime object used to
seed the value is timezone-naive.  The test would work fine in UTC+1
timezones, but not in other timezones.
No need to get convoluted about how a unix timestamp is derived from a
datetime object - it's right there in its methods.

Also adds type annotations to make it easer to reason about what the
arguments and results are.
@lunkwill42 lunkwill42 added the bug label Feb 27, 2024
@lunkwill42 lunkwill42 self-assigned this Feb 27, 2024
Copy link

sonarcloud bot commented Feb 27, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.10%. Comparing base (de2a90b) to head (8ff73b0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2831   +/-   ##
=======================================
  Coverage   57.10%   57.10%           
=======================================
  Files         567      567           
  Lines       41278    41278           
=======================================
  Hits        23571    23571           
  Misses      17707    17707           

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

Copy link

Test results

     12 files       12 suites   12m 9s ⏱️
3 303 tests 3 303 ✔️ 0 💤 0
9 384 runs  9 384 ✔️ 0 💤 0

Results for commit 8ff73b0.

@lunkwill42 lunkwill42 requested a review from hmpf February 28, 2024 11:46
@lunkwill42 lunkwill42 merged commit 127ce87 into Uninett:master Mar 1, 2024
12 checks passed
@lunkwill42 lunkwill42 deleted the bugfix/activeipcollector-naive-timestamp-test branch March 1, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants