From 17dbb6674db31c04bd74164f86c4bb8e6f2d8096 Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Tue, 3 Dec 2024 10:25:17 +0000 Subject: [PATCH] test: test cache expiry when fetching zones/schedules --- tests/test_module.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_module.py b/tests/test_module.py index 58caa72..29a0393 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -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() @@ -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()