Compare commits
No commits in common. "8a8480af32a16c9bcdafea031f4951eeee3f8250" and "99ec6afdfc8cd0a61cddd21e6ca167a5563dc76b" have entirely different histories.
8a8480af32
...
99ec6afdfc
3 changed files with 1 additions and 34 deletions
|
|
@ -28,7 +28,7 @@ def _project_lookup_by_alias(db: Path, alias: str) -> str:
|
||||||
"""
|
"""
|
||||||
conn = sqlite3.connect(db)
|
conn = sqlite3.connect(db)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute(f"SELECT * FROM 'projects' WHERE aliases = '{alias}'")
|
c.execute(f"SELECT * FROM 'projects' WHERE alias = '{alias}'")
|
||||||
results = c.fetchall()
|
results = c.fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
if len(results)>1:
|
if len(results)>1:
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
import corrlib.find as find
|
|
||||||
import sqlite3
|
|
||||||
from pathlib import Path
|
|
||||||
import corrlib.initialization as cinit
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def make_sql(path: Path) -> Path:
|
|
||||||
db = path / "test.db"
|
|
||||||
cinit._create_db(db)
|
|
||||||
return db
|
|
||||||
|
|
||||||
def test_find_lookup_by_one_alias(tmp_path: Path) -> None:
|
|
||||||
db = make_sql(tmp_path)
|
|
||||||
conn = sqlite3.connect(db)
|
|
||||||
c = conn.cursor()
|
|
||||||
uuid = "test_uuid"
|
|
||||||
alias_str = "fun_project"
|
|
||||||
tag_str = "tt"
|
|
||||||
owner = "tester"
|
|
||||||
code = "test_code"
|
|
||||||
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")
|
|
||||||
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'))",
|
|
||||||
(uuid, alias_str, tag_str, owner, code))
|
|
||||||
conn.commit()
|
|
||||||
with pytest.raises(Exception):
|
|
||||||
assert uuid == find._project_lookup_by_alias(db, "fun_project")
|
|
||||||
conn.close()
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue