Skip to content

Commit b63411a

Browse files
committed
not sure what's going on there....
1 parent 377a35f commit b63411a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/test_cache.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
from pathlib import Path
22
from tempfile import mkdtemp
3+
from sqlalchemy import MetaData
34

4-
from nomenklatura import settings
5+
from nomenklatura.db import get_engine
56
from nomenklatura.cache import Cache
67
from nomenklatura.dataset import Dataset
78

8-
DB_PATH = Path(mkdtemp()) / "test.sqlite3"
9-
settings.DB_URL = f"sqlite:///{DB_PATH.as_posix()}"
9+
10+
def _make_cache(dataset: Dataset) -> Cache:
11+
db_path = Path(mkdtemp()) / "test.sqlite3"
12+
url = f"sqlite:///{db_path.as_posix()}"
13+
engine = get_engine(url)
14+
metadata = MetaData()
15+
return Cache(engine, metadata, dataset, create=True)
1016

1117

1218
def test_cache():
1319
ds = Dataset.make({"name": "test", "title": "Test Case"})
14-
cache = Cache.make_default(ds)
20+
cache = _make_cache(ds)
1521
res = cache.get("name")
1622
assert res is None, res
1723
assert not cache.has("name")
@@ -39,13 +45,13 @@ def test_cache():
3945

4046
def test_cache_utils():
4147
ds = Dataset.make({"name": "test", "title": "Test Case"})
42-
cache = Cache.make_default(ds)
48+
cache = _make_cache(ds)
4349
assert hash(cache) != 0
4450

4551

4652
def test_preload_cache():
4753
ds = Dataset.make({"name": "test", "title": "Test Case"})
48-
cache = Cache.make_default(ds)
54+
cache = _make_cache(ds)
4955
res = cache.get("name")
5056
cache.set("name", "TestCase")
5157
assert len(cache._preload) == 0, cache._preload

0 commit comments

Comments
 (0)