diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-06 14:58:14 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-06 14:58:14 +0530 |
commit | 47b68d56d831d234c44da9530373b95dae338ea4 (patch) | |
tree | 286455da83e2ad6c7992a9cea9d92bc83484198c /app | |
parent | a1a5fcdcd2380d7130938dd69afd87eb7b544d2e (diff) |
add test for verified email
Diffstat (limited to 'app')
-rw-r--r-- | app/tests/conftest.py | 2 | ||||
-rw-r--r-- | app/tests/test_views.py | 19 |
2 files changed, 20 insertions, 1 deletions
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 |