mirror of
https://github.com/senju1337/senju.git
synced 2025-12-24 07:39:29 +00:00
test: store_manager sanity check
Refs: OPS.19
This commit is contained in:
parent
e6b10ce96e
commit
5aba3981ee
2 changed files with 28 additions and 0 deletions
|
|
@ -3,8 +3,15 @@ from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from senju.store_manager import StoreManager
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def temp_data_dir():
|
def temp_data_dir():
|
||||||
"""Create a temporary directory for test data"""
|
"""Create a temporary directory for test data"""
|
||||||
return Path(tempfile.mkdtemp())
|
return Path(tempfile.mkdtemp())
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def store_manager(temp_data_dir):
|
||||||
|
return StoreManager(temp_data_dir/"store.db")
|
||||||
|
|
|
||||||
21
tests/test_store.py
Normal file
21
tests/test_store.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# do not remove this import. This is needed for
|
||||||
|
# pytest fixtures to work
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from senju.store_manager import StoreManager # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
|
def test_temp_data_dir(store_manager: StoreManager):
|
||||||
|
thing = {
|
||||||
|
"color": "blue",
|
||||||
|
"number": 19,
|
||||||
|
"inner": {
|
||||||
|
"no": "yes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thing_id = store_manager.save(thing)
|
||||||
|
thing_loaded = store_manager.load(thing_id)
|
||||||
|
if thing_loaded is None:
|
||||||
|
assert False, "the store manager load did not return anything"
|
||||||
|
for key in thing.keys():
|
||||||
|
assert thing[key] == thing_loaded[key]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue