From 0cc7065dac62f055568f8593871426e68048f8a1 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Thu, 8 Jul 2021 12:12:07 +0300 Subject: [PATCH] =?UTF-8?q?fix=20flaky=20test=5Fbackfill=5Fmonthly=5Fmetri?= =?UTF-8?q?cs=5Ffor=5Fsite=20by=20freezing=20time=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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. --- devsite/requirements/test.txt | 2 ++ tests/test_backfill.py | 1 + tox.ini | 1 + 3 files changed, 4 insertions(+) create mode 100644 devsite/requirements/test.txt diff --git a/devsite/requirements/test.txt b/devsite/requirements/test.txt new file mode 100644 index 00000000..32f9bcfd --- /dev/null +++ b/devsite/requirements/test.txt @@ -0,0 +1,2 @@ +# Shared testing requirements +pytest-freezegun==0.4.2 diff --git a/tests/test_backfill.py b/tests/test_backfill.py index 2b960a03..e765f909 100644 --- a/tests/test_backfill.py +++ b/tests/test_backfill.py @@ -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 diff --git a/tox.ini b/tox.ini index 7705f477..405aae5f 100644 --- a/tox.ini +++ b/tox.ini @@ -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