Add tests
Committed df0a62
index 0000000..f994a50
--- /dev/null
+import pathlib
+
+import sqlyte
+import web
+
+import webint_owner
+
+db_path = pathlib.Path("site.db")
+db_path_shm = pathlib.Path("site.db-shm")
+db_path_wal = pathlib.Path("site.db-wal")
+
+
+def unlink():
+ db_path.unlink()
+ db_path_shm.unlink()
+ db_path_wal.unlink()
+
+
+def test_passphrase():
+ db = sqlyte.db(db_path, webint_owner.app._model)
+ passphrase = webint_owner.update_passphrase(db)
+ assert len(passphrase) == 7
+ salted_hash = webint_owner.get_passphrase(db)
+ assert web.verify_passphrase(
+ salted_hash["passphrase_salt"],
+ salted_hash["passphrase_hash"],
+ "".join(passphrase),
+ )
+ unlink()
+
+
+def test_identity():
+ name = "Testy McTester"
+ db = sqlyte.db(db_path, webint_owner.app._model)
+ webint_owner.add_identity(db, name)
+ assert webint_owner.get_identity(db)["card"]["name"][0] == name
+ nickname = "liltest"
+ note = "Testing in the testiverse."
+ webint_owner.update_details(db, name=name, nickname=nickname, note=note)
+ identity = webint_owner.get_identity(db)
+ assert identity["card"]["nickname"][0] == nickname
+ assert identity["card"]["note"][0] == note
+ unlink()
--- a/webint_owner/__init__.py
+++ b/webint_owner/__init__.py
try:
return db.select("passphrases", order="created DESC")[0]
except IndexError:
- return None
+ return {}
@app.query