forked from Bamimore-Tomi/fauna-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
26 lines (22 loc) · 940 Bytes
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest, random, string
from main import app
class TestCases(unittest.TestCase):
def test_home(self):
with app.test_client(self) as client:
get_response = client.get("/")
self.assertEqual(get_response.status_code, 302)
def test_register(self):
with app.test_client(self) as client:
# Generate dummy username
username = "".join([random.choice(string.ascii_letters) for i in range(7)])
post_response_1 = client.post(
"/register",
data={
"email": username + "@gmail.com",
"username": f"test-{username}",
"password": f"password-{username}",
},
)
# test is successful registration return a redirect to the login page
self.assertEqual(post_response_1.status_code, 302)
post_detials = tester.post()