-
Hi, i have question about testing the app. How actualy i can pass test the page with protected view with @auth_required ? i'm new in testing and mostly i'm using pytest and flask-pytest to test. May you have documentation or references to doing this ? Thankyou |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
i have checked several blog and tutorial and i doing this thing, but i have error that make me ask more about it. i follow the instruction in documentation that testing configuration checklist and i create simple test to login (i'm using pytest and pytes-flask) def test_security_login_page(client):
rv = client.get(url_for_security("login"), follow_redirects=True)
assert rv.status_code == HTTPStatus.OK
assert b"Email" in rv.data
assert b"Password" in rv.data
def test_security_login_user(client):
rv = client.post(
url_for_security("login"),
data=dict(email=EMAIL, password=PASSWORD, follow_redirects=True),
)
assert rv.status_code == HTTPStatus.OK
assert b"Postingan Terbaru" in rv.data both test stuck in views error that says : > {{ login_user_form.csrf_token() }}
E jinja2.exceptions.UndefinedError: 'flask_security.forms.LoginForm object' has no attribute 'csrf_token' Yeah, the Packages :
|
Beta Was this translation helpful? Give feedback.
i have checked several blog and tutorial and i doing this thing, but i have error that make me ask more about it.
i follow the instruction in documentation that testing configuration checklist and i create simple test to login (i'm using pytest and pytes-flask)