-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit-test.py
37 lines (28 loc) · 916 Bytes
/
unit-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
from app import app
import unittest
class FlaskBookshelfTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass
@classmethod
def tearDownClass(cls):
pass
def setUp(self):
# creates a test client
self.app = app.test_client()
# propagate the exceptions to the test client
self.app.testing = True
def tearDown(self):
pass
def test_home_status_code(self):
# sends HTTP GET request to the application
# on the specified path
result = self.app.get('/')
# assert the status code of the response
self.assertEqual(result.status_code, 200)
def test_home_data(self):
# sends HTTP GET request to the application
# on the specified path
result = self.app.get('/')
# assert the response data
self.assertEqual(result.data, "Tests passed, yay!")