atst/tests/routes/test_errors.py
2019-05-13 09:35:31 -04:00

23 lines
566 B
Python

import pytest
from flask import url_for
@pytest.fixture
def csrf_enabled_app(app):
app.config.update({"WTF_CSRF_ENABLED": True})
yield app
app.config.update({"WTF_CSRF_ENABLED": False})
def test_csrf_error(csrf_enabled_app, client):
response = client.post(
url_for("users.user"),
headers={"Content-Type": "application/x-www-form-urlencoded"},
data="csrf_token=invalid_token",
follow_redirects=True,
)
body = response.data.decode()
assert "Session Expired" in body
assert "Log in required" in body