Debian Codegraph @

examples/flaskr/tests/test_init.py

raw
1 from flaskr import create_app
2
3
4 def test_config():
5 """Test create_app without passing test config."""
6 assert not create_app().testing
7 assert create_app({"TESTING": True}).testing
8
9
10 def test_db_url_environ(monkeypatch):
11 """Test DATABASE_URL environment variable."""
12 monkeypatch.setenv("DATABASE_URL", "sqlite:///environ")
13 app = create_app()
14 assert app.config["SQLALCHEMY_DATABASE_URI"] == "sqlite:///environ"
15
16
17 def test_init_db_command(runner, monkeypatch):
18 called = False
19
20 def fake_init_db():
21 nonlocal called
22 called = True
23
24 monkeypatch.setattr("flaskr.init_db", fake_init_db)
25 result = runner.invoke(args=["init-db"])
26 assert "Initialized" in result.output
27 assert called