-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
97 lines (81 loc) · 3.42 KB
/
test.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from SparkApp import app
import unittest
class FlaskTestCase(unittest.TestCase):
# Ensure that flask was set up correctly.
def test_index(self):
tester = app.test_client(self)
response = tester.get('/', content_type='html/text')
self.assertEqual(response.status_code, 200)
# Ensure that the login page loads correctly.
def test_login_page_loads(self):
tester = app.test_client(self)
response = tester.get('/')
self.assertIn(b'SIGN IN', response.data)
# Ensure that the register page loads correctly.
def test_register_page_loads(self):
tester = app.test_client(self)
response = tester.get('/register')
self.assertIn(b'SIGN UP', response.data)
# Ensure username has more than one character.
def test_correct_username(self):
tester = app.test_client()
response = tester.post(
'/register',
data=dict(username="a"),
follow_redirects=True
)
self.assertIn(b'Username must contain between 2 to 30 characters!', response.data)
# Ensure email is valid.
def test_correct_email(self):
tester = app.test_client()
response = tester.post(
'/register',
data=dict(email="cyril"),
follow_redirects=True
)
self.assertIn(b'Not a valid email address!', response.data)
# Ensure mobile number is of 10 digits.
def test_correct_mobile(self):
tester = app.test_client()
response = tester.post(
'/register',
data=dict(mobile="1"),
follow_redirects=True
)
self.assertIn(b'Mobile No. must be 10 digits', response.data)
# Ensure password is atleast 6 characters.
def test_correct_password(self):
tester = app.test_client()
response = tester.post(
'/register',
data=dict(password="123"),
follow_redirects=True
)
self.assertIn(b'Password must have atleast 6 characters!', response.data)
# # Ensure that the teacher dashboard page loads correctly
# def test_teacher_page_loads(self):
# tester = app.test_client(self)
# response = tester.get('/teacher')
# self.assert(b'Welcome Teacher!', response.data)
# # Ensure that the student dashboard page loads correctly
# def test_student_page_loads(self):
# tester = app.test_client(self)
# response = tester.get('/student')
# self.assertIn(b'Welcome Student!', response.data)
# # Ensure that the assesment page loads correctly
# def test_assesment_page_loads(self):
# tester = app.test_client(self)
# response = tester.get('/assesment')
# self.assertIn(b'Answer the following questions with a value ranging from 1 to 10', response.data)
# # Ensure that the critical thinking game page loads correctly
# def test_critical_thinking_game_page_loads(self):
# tester = app.test_client(self)
# response = tester.get('/critical_thinking')
# self.assertIn(b'Game to improve critical thinking skills', response.data)
# # Ensure that the communication game page loads correctly
# def test_communication_game_page_loads(self):
# tester = app.test_client(self)
# response = tester.get('/communication')
# self.assertIn(b'Game to improve communication skills', response.data)
if __name__ == '__main__':
unittest.main()