Skip to content
Snippets Groups Projects

Port init elements code

Merged Manon Blanco requested to merge init-element-worker into master
Files
8
tests/__init__.py 0 → 100644
+ 31
0
import json
import sqlite3
from pathlib import Path
from arkindex_worker.cache import SQL_VERSION
def check_json(json_path: Path, elements: list) -> None:
assert json_path.is_file()
assert json.loads(json_path.read_text()) == elements
def check_db(db_path: Path, elements: list, images: list) -> None:
assert db_path.is_file()
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()))
== elements
)
assert (
list(map(dict, db.execute("select * from images order by id").fetchall()))
== images
)
db.close()
Loading