From 47b68d56d831d234c44da9530373b95dae338ea4 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sun, 6 Jun 2021 14:58:14 +0530 Subject: add test for verified email --- app/tests/conftest.py | 2 ++ app/tests/test_views.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/tests/conftest.py b/app/tests/conftest.py index 1da24d3..0fd1ef1 100644 --- a/app/tests/conftest.py +++ b/app/tests/conftest.py @@ -9,6 +9,8 @@ import os def app(): flask_app.config['WTF_CSRF_ENABLED'] = False flask_app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///" + tempfile.mkstemp(suffix='.db')[-1] + flask_app.config['MAIL_BACKEND'] = "file" #"locmem" + flask_app.config["MAIL_FILE_PATH"] = '/tmp/app-messages' db.create_all() yield flask_app diff --git a/app/tests/test_views.py b/app/tests/test_views.py index dbf8cb5..a9645b2 100644 --- a/app/tests/test_views.py +++ b/app/tests/test_views.py @@ -1,3 +1,7 @@ +from itsdangerous.url_safe import URLSafeSerializer +from app import app as flask_app +ts = URLSafeSerializer(flask_app.config["SECRET_KEY"]) + data2check_visitors = { "/index": { "code": 200, "data": b"Nice Tagline" @@ -46,8 +50,21 @@ def test_user_auth_flow(app, client): ), follow_redirects=True) assert res.status_code == 200 + assert b"confirm your email" in res.data + + confirmation_token = ts.dumps("test@example.com",salt="email-confirm-key") + res = client.get("/confirm?confirmation_token={}".format(confirmation_token), + follow_redirects=True) + print(res.data) + assert b"Succesfully Verified" in res.data + + res = client.post("/signin",data=dict( + email="test@example.com", + password="testpassword"), + follow_redirects=True) + assert res.status_code == 200 assert b"Hi John" in res.data - + res = client.get("/logout", follow_redirects=True) assert res.status_code == 200 assert b"You have been logged out." in res.data -- cgit v1.2.3