mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Add simple caching implementation for database queries that will be used in command autocompletion
This commit is contained in:
parent
f0a05c8b4d
commit
72c3acbcc2
9 changed files with 162 additions and 50 deletions
0
tests/test_database/test_utils/__init__.py
Normal file
0
tests/test_database/test_utils/__init__.py
Normal file
27
tests/test_database/test_utils/test_caches.py
Normal file
27
tests/test_database/test_utils/test_caches.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.models import UforaCourse
|
||||
from database.utils.caches import UforaCourseCache
|
||||
|
||||
|
||||
async def test_ufora_course_cache_refresh_empty(database_session: AsyncSession, ufora_course_with_alias: UforaCourse):
|
||||
"""Test loading the data for the Ufora Course cache when it's empty"""
|
||||
cache = UforaCourseCache()
|
||||
await cache.refresh(database_session)
|
||||
|
||||
assert len(cache.data) == 2
|
||||
assert cache.data == ["alias", "test"]
|
||||
|
||||
|
||||
async def test_ufora_course_cache_refresh_not_empty(
|
||||
database_session: AsyncSession, ufora_course_with_alias: UforaCourse
|
||||
):
|
||||
"""Test loading the data for the Ufora Course cache when it's not empty anymore"""
|
||||
cache = UforaCourseCache()
|
||||
cache.data = ["Something"]
|
||||
cache.data_transformed = ["something"]
|
||||
|
||||
await cache.refresh(database_session)
|
||||
|
||||
assert len(cache.data) == 2
|
||||
assert cache.data == ["alias", "test"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue