-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunittest.py
More file actions
36 lines (29 loc) · 1.12 KB
/
unittest.py
File metadata and controls
36 lines (29 loc) · 1.12 KB
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
from app 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('/login', content_type='html/text')
self.assertEqual(response.status_code, 200)
# check if content return is application/json
def test_index_content(self):
tester = app.test_client(self)
response = tester.get('/login')
self.assertEqual(response.content_type, 'application/json')
# check data returned
def test_index_data(self):
tester = app.test_client(self)
response = tester.get('/login')
self.assertTrue(b'msg' in response.data)
# Ensure that login behaves correctly given the correct credentials
def test_correct_login(self):
tester = app.test_client(self)
response = tester.post(
'/login',
data=dict(email="chalindu.18@cse.mrt.ac.lk", password="Password"),
follow_redirects=True
)
# self.assertEqual("msg", response.data)
if __name__ == '__main__':
unittest.main()