Skip to content

Commit

Permalink
Using constant in test
Browse files Browse the repository at this point in the history
  • Loading branch information
IanWoodard committed Dec 12, 2024
1 parent 5c56ab1 commit fd3eebc
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/utils/test_check_for_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from freezegun import freeze_time

from devservices.constants import DEVSERVICES_LATEST_VERSION_CACHE_TTL
from devservices.constants import DEVSERVICES_RELEASES_URL
from devservices.utils.check_for_update import check_for_update

Expand Down Expand Up @@ -74,7 +75,11 @@ def test_check_for_update_cached_fresh(mock_urlopen: mock.Mock, tmp_path: Path)
freeze_time("2024-05-14 05:43:21"),
mock.patch(
"devservices.utils.check_for_update.os.path.getmtime",
return_value=(datetime.now() - timedelta(minutes=14)).timestamp(),
return_value=(
datetime.now()
- DEVSERVICES_LATEST_VERSION_CACHE_TTL
+ timedelta(minutes=1)
).timestamp(),
),
mock.patch(
"devservices.utils.check_for_update.DEVSERVICES_CACHE_DIR",
Expand Down Expand Up @@ -104,7 +109,9 @@ def test_check_for_update_cached_stale_without_update(
freeze_time("2024-05-14 05:43:21"),
mock.patch(
"devservices.utils.check_for_update.os.path.getmtime",
return_value=(datetime.now() - timedelta(minutes=16)).timestamp(),
return_value=(
datetime.now() - DEVSERVICES_LATEST_VERSION_CACHE_TTL
).timestamp(),
),
mock.patch(
"devservices.utils.check_for_update.DEVSERVICES_CACHE_DIR",
Expand Down Expand Up @@ -138,7 +145,11 @@ def test_check_for_update_cached_stale_with_update(
freeze_time("2024-05-14 05:43:21"),
mock.patch(
"devservices.utils.check_for_update.os.path.getmtime",
return_value=(datetime.now() - timedelta(minutes=16)).timestamp(),
return_value=(
datetime.now()
- DEVSERVICES_LATEST_VERSION_CACHE_TTL
- timedelta(minutes=1)
).timestamp(),
),
mock.patch(
"devservices.utils.check_for_update.DEVSERVICES_CACHE_DIR",
Expand Down

0 comments on commit fd3eebc

Please sign in to comment.