dankventskalender migrate to flask
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

29 lines
627B

  1. import sqlite3
  2. import pytest
  3. from calender.db import get_db
  4. def test_get_close_db(app):
  5. with app.app_context():
  6. db = get_db()
  7. assert db is get_db()
  8. with pytest.raises(sqlite3.ProgrammingError) as e:
  9. db.execute('SELECT 1')
  10. assert 'closed' in str(e.value)
  11. def test_init_db_command(runner, monkeypatch):
  12. class Recorder(object):
  13. called = False
  14. def fake_init_db():
  15. Recorder.called = True
  16. monkeypatch.setattr('calender.db.init_db', fake_init_db)
  17. result = runner.invoke(args=['init-db'])
  18. assert 'Initialized' in result.output
  19. assert Recorder.called