Compare commits

..

2 commits

Author SHA1 Message Date
85698c377b
use uniqueness for complete db check
Some checks failed
Mypy / mypy (push) Failing after 1m11s
Pytest / pytest (3.12) (push) Failing after 1m14s
Pytest / pytest (3.13) (push) Failing after 1m8s
Pytest / pytest (3.14) (push) Failing after 1m9s
Ruff / ruff (push) Failing after 59s
2026-04-14 16:42:39 +02:00
65cd55ec0a
add test on whether paths are indeed unique 2026-04-14 16:36:31 +02:00

View file

@ -15,9 +15,21 @@ def has_valid_times(result: pd.DataFrame) -> bool:
return False
return True
def are_keys_unique(db: Path, table: str, col: str) -> bool:
conn = sqlite3.connect(db)
c = conn.cursor()
c.execute(f"SELECT COUNT( DISTINCT CAST(path AS nvarchar(4000))), COUNT({col}) FROM {table};")
results = c.fetchall()[0]
conn.close()
return bool(results[0] == results[1])
def check_db_integrity(path: Path) -> None:
db = get_db_file(path)
if not are_keys_unique(db, 'backlogs', 'path'):
raise Exception("The paths the backlog table of the database links are not unique.")
search_expr = "SELECT * FROM 'backlogs'"
conn = sqlite3.connect(db)
results = pd.read_sql(search_expr, conn)
@ -27,6 +39,7 @@ def check_db_integrity(path: Path) -> None:
raise ValueError(f"Result with id {result[id]} has wrong time signatures.")
def full_integrity_check(path: Path) -> None:
check_db_integrity(path)