2022-07-27 21:10:43 +02:00
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
|
2022-07-25 21:20:09 +02:00
|
|
|
from database.schemas.relational import UforaCourse
|
2022-07-14 22:44:22 +02:00
|
|
|
from database.utils.caches import UforaCourseCache
|
|
|
|
|
|
|
|
|
2022-07-27 21:10:43 +02:00
|
|
|
async def test_ufora_course_cache_refresh_empty(postgres: AsyncSession, ufora_course_with_alias: UforaCourse):
|
2022-07-14 22:44:22 +02:00
|
|
|
"""Test loading the data for the Ufora Course cache when it's empty"""
|
|
|
|
cache = UforaCourseCache()
|
2022-08-10 01:04:19 +02:00
|
|
|
await cache.invalidate(postgres)
|
2022-07-14 22:44:22 +02:00
|
|
|
|
2022-07-18 23:23:53 +02:00
|
|
|
assert len(cache.data) == 1
|
|
|
|
assert cache.data == ["test"]
|
|
|
|
assert cache.aliases == {"alias": "test"}
|
2022-07-14 22:44:22 +02:00
|
|
|
|
|
|
|
|
2022-07-27 21:10:43 +02:00
|
|
|
async def test_ufora_course_cache_refresh_not_empty(postgres: AsyncSession, ufora_course_with_alias: UforaCourse):
|
2022-07-14 22:44:22 +02:00
|
|
|
"""Test loading the data for the Ufora Course cache when it's not empty anymore"""
|
|
|
|
cache = UforaCourseCache()
|
|
|
|
cache.data = ["Something"]
|
|
|
|
cache.data_transformed = ["something"]
|
|
|
|
|
2022-08-10 01:04:19 +02:00
|
|
|
await cache.invalidate(postgres)
|
2022-07-14 22:44:22 +02:00
|
|
|
|
2022-07-18 23:23:53 +02:00
|
|
|
assert len(cache.data) == 1
|
|
|
|
assert cache.data == ["test"]
|
|
|
|
assert cache.aliases == {"alias": "test"}
|