summaryrefslogtreecommitdiff
path: root/tests/test_db.py
diff options
context:
space:
mode:
authorTom Harley2021-07-10 21:41:09 +0000
committerTom Harley2021-07-11 14:23:35 +0000
commitc4e848c21c028ca7c52846ea1abd7f3a38aff7d6 (patch)
treefb886b06dcdd4d9ae4cc54ee9ea9f481ec124166 /tests/test_db.py
parentAdd basic inbox/outbox functionality (diff)
downloadswap-c4e848c21c028ca7c52846ea1abd7f3a38aff7d6.tar.gz
swap-c4e848c21c028ca7c52846ea1abd7f3a38aff7d6.zip

Add more inbox/outbox tests

HEADmaster

Still not even total coverage!

Need to:

  • write more tests for outbox manipulation
  • look into and implement receiving content from other servers (+ write tests)

off the top of my head.

Diffstat (limited to 'tests/test_db.py')
-rw-r--r--tests/test_db.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_db.py b/tests/test_db.py
index 7a35593..f11a95a 100644
--- a/tests/test_db.py
+++ b/tests/test_db.py
@@ -28,3 +28,17 @@ def test_init_db_command(runner, monkeypatch):
assert "Initialised" in result.output
assert Recorder.called
+
+
+def test_add_user_command(app, runner):
+ with app.app_context():
+ db = get_db()
+ old_count = db.execute("select count(*) from users;").fetchone()["count(*)"]
+ runner.invoke(args=["add-user", "mag", "pass"])
+ new_count = db.execute("select count(*) from users;").fetchone()["count(*)"]
+ assert new_count == old_count + 1
+
+ user_entries = db.execute(
+ "select count(*) from users where username=?", ("mag",)
+ ).fetchall()
+ assert len(user_entries) == 1