Skip to content

Commit

Permalink
test: test cache expiry when fetching zones/schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Dec 3, 2024
1 parent df2dafd commit 17dbb66
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ async def test_zones_cache(test_module):
assert initial_fetch_time == test_module._last_fetched


@pytest.mark.asyncio
async def test_zones_cache_expired(test_module_short_cache):
await test_module_short_cache.zones()
initial_fetch_time = test_module_short_cache._last_fetched
await asyncio.sleep(0.25)

await test_module_short_cache.zones()
assert initial_fetch_time != test_module_short_cache._last_fetched


@pytest.mark.asyncio
async def test_zones_force_refresh(test_module):
await test_module.zones()
Expand Down Expand Up @@ -119,6 +129,16 @@ async def test_schedules_cache(test_module):
assert initial_fetch_time == test_module._last_fetched


@pytest.mark.asyncio
async def test_schedules_cache_expired(test_module_short_cache):
await test_module_short_cache.schedules()
initial_fetch_time = test_module_short_cache._last_fetched
await asyncio.sleep(0.5)

await test_module_short_cache.schedules()
assert initial_fetch_time != test_module_short_cache._last_fetched


@pytest.mark.asyncio
async def test_schedules_force_refresh(test_module):
await test_module.schedules()
Expand Down

0 comments on commit 17dbb66

Please sign in to comment.