mirror of
https://github.com/simple-login/app.git
synced 2025-02-20 22:02:54 +08:00
use .env.example in test, disable CSRF in tests
This commit is contained in:
parent
32d6af228b
commit
067b8eef71
2 changed files with 9 additions and 2 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue