29 lines
897 B
Python
29 lines
897 B
Python
"""Generate non-sensitive database fixtures for CI."""
|
|||
|
|
|
||
|
|
import json
|
||
|
|
import sqlite3
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
|
||
|
|
def create_fixtures(assets: Path) -> None:
|
||
|
|
assets.mkdir(parents=True, exist_ok=True)
|
||
|
|
with sqlite3.connect(assets / "absdatabase.sqlite_test") as db:
|
||
|
|
db.execute(
|
||
|
|
"CREATE TABLE books (id INTEGER PRIMARY KEY, title TEXT, genres TEXT, audioFiles TEXT)"
|
||
|
|
)
|
||
|
|
db.execute("CREATE TABLE libraries (id INTEGER PRIMARY KEY, name TEXT)")
|
||
|
|
db.execute("INSERT INTO libraries VALUES (1, 'Test Library')")
|
||
|
|
db.execute(
|
||
|
|
"INSERT INTO books VALUES (?, ?, ?, ?)",
|
||
|
|
(
|
||
|
|
1,
|
||
|
|
"Test Book",
|
||
|
|
json.dumps(["Sci-Fi"]),
|
||
|
|
json.dumps([{"metaTags": {"tagComment": "short"}}]),
|
||
|
|
),
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
create_fixtures(Path(sys.argv[1]))
|