Introduce thin wrapper for SQL calls
All checks were successful
Mypy / mypy (push) Successful in 1m11s
Pytest / pytest (3.12) (push) Successful in 1m19s
Pytest / pytest (3.13) (push) Successful in 1m14s
Pytest / pytest (3.14) (push) Successful in 1m16s
Ruff / ruff (push) Successful in 1m3s
Mypy / mypy (pull_request) Successful in 1m13s
Pytest / pytest (3.12) (pull_request) Successful in 1m18s
Pytest / pytest (3.13) (pull_request) Successful in 1m12s
Pytest / pytest (3.14) (pull_request) Successful in 1m15s
Ruff / ruff (pull_request) Successful in 1m0s

This commit is contained in:
Justus Kuhlmann 2026-04-21 10:22:46 +02:00
commit d6de8e6387
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
3 changed files with 35 additions and 16 deletions

View file

@ -9,12 +9,17 @@ import datetime as dt
def make_sql(path: Path) -> Path:
db = path / "test.db"
db = path / "backlogger.db"
cinit._create_db(db)
return db
def make_config(path: Path) -> None:
cinit._write_config(path, cinit._create_config(path, "datalad", False))
def test_find_lookup_by_one_alias(tmp_path: Path) -> None:
make_config(tmp_path)
db = make_sql(tmp_path)
conn = sqlite3.connect(db)
c = conn.cursor()
@ -26,7 +31,7 @@ def test_find_lookup_by_one_alias(tmp_path: Path) -> None:
c.execute("INSERT INTO projects (id, aliases, customTags, owner, code, created_at, updated_at) VALUES (?, ?, ?, ?, ?, datetime('now'), datetime('now'))",
(uuid, alias_str, tag_str, owner, code))
conn.commit()
assert uuid == find._project_lookup_by_alias(db, "fun_project")
assert uuid == find._project_lookup_by_alias(tmp_path, "fun_project")
uuid = "test_uuid2"
alias_str = "fun_project"
c.execute("INSERT INTO projects (id, aliases, customTags, owner, code, created_at, updated_at) VALUES (?, ?, ?, ?, ?, datetime('now'), datetime('now'))",
@ -36,7 +41,9 @@ def test_find_lookup_by_one_alias(tmp_path: Path) -> None:
assert uuid == find._project_lookup_by_alias(db, "fun_project")
conn.close()
def test_find_lookup_by_id(tmp_path: Path) -> None:
make_config(tmp_path)
db = make_sql(tmp_path)
conn = sqlite3.connect(db)
c = conn.cursor()
@ -49,7 +56,7 @@ def test_find_lookup_by_id(tmp_path: Path) -> None:
(uuid, alias_str, tag_str, owner, code))
conn.commit()
conn.close()
result = find._project_lookup_by_id(db, uuid)[0]
result = find._project_lookup_by_id(tmp_path, uuid)[0]
assert uuid == result[0]
assert alias_str == result[1]
assert tag_str == result[2]