From 350dc6430a35696efaaa4d5d736f3faed9be73ae Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Fri, 4 Jun 2021 15:18:39 +0530 Subject: added auth view --- app/tests/test_views.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'app/tests/test_views.py') diff --git a/app/tests/test_views.py b/app/tests/test_views.py index 1ce1cf2..5f6d938 100644 --- a/app/tests/test_views.py +++ b/app/tests/test_views.py @@ -30,4 +30,46 @@ def test_visitors(app, client): res = client.get(page) print("Testing %s",page) assert res.status_code == data2check_visitors[page]["code"] - assert data2check_visitors[page]["data"] in res.data \ No newline at end of file + assert data2check_visitors[page]["data"] in res.data + +def test_user_auth_flow(app, client): + res = client.post("/signup",data=dict( + email="test@example.com", + first_name="John", + 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 + + 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") + res = client.post("/signin",data=dict( + email="testtest@example.com", + password="123456"),follow_redirects=True) + assert res.status_code == 200 + assert b"Incorrect Email" in res.data + res = client.post("/signin",data=dict( + email="test@example.com", + password="incorrectpassword"), + follow_redirects = True) + assert res.status_code == 200 + assert b"Incorrect Password" in res.data + + res = client.post("/signup",data=dict( + email="test@example.com", + first_name="John", + password="testpassword", + ), follow_redirects=True) + assert res.status_code == 200 + assert b"Oops! An account with that email already exists" in res.data \ No newline at end of file -- cgit v1.2.3