use .env.example in test, disable CSRF in tests

This commit is contained in:
Son NK 2019-07-12 11:35:30 +02:00 committed by Son NK
parent 32d6af228b
commit 067b8eef71
2 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,9 @@
import os
os.environ["CONFIG"] = ".env.example"
os.environ["CONFIG"] = os.path.abspath(
os.path.join(os.path.dirname(os.path.dirname(__file__)), ".env.example")
)
# use in-memory database
# need to set before importing any other module as DB_URI is init at import time
@ -16,7 +19,10 @@ from server import create_app
def flask_app():
app = create_app()
# use in-memory database
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
app.config["TESTING"] = True
app.config["WTF_CSRF_ENABLED"] = False
with app.app_context():
db.create_all()
@ -31,6 +37,7 @@ def flask_client():
# use in-memory database
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
app.config["TESTING"] = True
app.config["WTF_CSRF_ENABLED"] = False
client = app.test_client()

View File

@ -3,4 +3,4 @@ def test_redirect_login_page(flask_client):
rv = flask_client.get("/")
assert rv.status_code == 302
assert rv.location == "http://localhost/auth/login"
assert rv.location == "http://sl.local/auth/login"