Skip to content
Snippets Groups Projects

Draft: Migrate cache to use the Arkindex export structure

Open Manon Blanco requested to merge cache-use-arkindex-export into master
5 files
+ 119
125
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 19
6
@@ -2,7 +2,9 @@ import json
import sqlite3
from pathlib import Path
from arkindex_worker.cache import SQL_VERSION
from arkindex_export import Image as CachedImage
from arkindex_worker.cache import CachedElement
def check_json(json_path: Path, elements: list) -> None:
@@ -16,15 +18,26 @@ def check_db(db_path: Path, elements: list, images: list) -> None:
db = sqlite3.connect(str(db_path))
db.row_factory = sqlite3.Row
assert list(map(dict, db.execute("select * from version").fetchall())) == [
{"version": SQL_VERSION}
]
assert (
list(map(dict, db.execute("select * from elements order by id").fetchall()))
list(
map(
dict,
db.execute(
f"select {','.join(key for key in CachedElement._meta.columns if key not in ['created', 'updated'])} from {CachedElement._meta.table_name} order by id"
).fetchall(),
)
)
== elements
)
assert (
list(map(dict, db.execute("select * from images order by id").fetchall()))
list(
map(
dict,
db.execute(
f"select * from {CachedImage._meta.table_name} order by id"
).fetchall(),
)
)
== images
)
Loading