Skip to content

Commit

Permalink
fix flaky test_backfill_monthly_metrics_for_site by freezing time …
Browse files Browse the repository at this point in the history
`test_backfill_monthly_metrics_for_site` seems to fail sometimes depending on the time it's being run. using [pytest-freezegun](https://pypi.org/project/pytest-freezegun/) to freeze the time and make sure it returns consistent results.
  • Loading branch information
OmarIthawi committed Jul 8, 2021
1 parent f830b6c commit 0cc7065
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions devsite/requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Shared testing requirements
pytest-freezegun==0.4.2
1 change: 1 addition & 0 deletions tests/test_backfill.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def backfill_test_data(db):
)


@pytest.mark.freeze_time('2019-09-01 12:00:00')
def test_backfill_monthly_metrics_for_site(backfill_test_data):
"""Simple coverage and data validation check for the function under test
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ deps =
hawthorn_multisite: -r{toxinidir}/devsite/requirements/hawthorn_multisite.txt
juniper_community: -r{toxinidir}/devsite/requirements/juniper_community.txt
juniper_multisite: -r{toxinidir}/devsite/requirements/juniper_multisite.txt
-r{toxinidir}/devsite/requirements/test.txt

whitelist_externals =
git
Expand Down

0 comments on commit 0cc7065

Please sign in to comment.