fixed typos and added tests for db and auth

This commit is contained in:
2021-10-11 22:14:06 -06:00
parent dffc3e983d
commit 30b21dbde6
3 changed files with 71 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
import sqlite3
import pytest
from flaskfdx.db import get_db
def test_get_close_db(app):
with app.app_context():
db = get_db()
assert db is get_db()
with pytest.raises(sqlite3.ProgrammingError) as e:
db.execute('SELECT 1')
assert 'closed' in str(e.value)
def test_init_db_command(runner, monkeypatch):
class Recorder(object):
called = False
def fake_init_db():
Recorder.called = True
monkeypatch.setattr('flaskfdx.db.init_db', fake_init_db)
result = runner.invoke(args=['init-db'])
assert 'initialized' in result.output
assert Recorder.called