-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_run.py
83 lines (54 loc) · 2.67 KB
/
test_run.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
# import os
import unittest
from run import app
class BasicTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass
@classmethod
def tearDownClass(cls):
pass
# SETUP and TEARDOWN
def setUp(self):
pass
def tearDown(self):
pass
# TESTS
def test_get_routes_no_params(self):
tester = app.test_client(self)
response = tester.get('/', content_type="html/text")
self.assertEqual(response.status_code, 200)
response = tester.get('/get_food_items', content_type="html/text")
self.assertEqual(response.status_code, 200)
response = tester.get('/add_food_item', content_type="html/text")
self.assertEqual(response.status_code, 200)
response = tester.get('/get_classification', content_type="html/text")
self.assertEqual(response.status_code, 200)
response = tester.get('/add_class', content_type="html/text")
self.assertEqual(response.status_code, 200)
response = tester.get('/dashboard', content_type="html/text")
self.assertEqual(response.status_code, 200)
response = tester.get('/about', content_type="html/text")
self.assertEqual(response.status_code, 200)
response = tester.get('/contact', content_type="html/text")
self.assertEqual(response.status_code, 200)
def test_get_routes_no_params_connect_to_correct_template(self):
tester = app.test_client(self)
response = tester.get('/', content_type="html/text")
self.assertTrue(b'Nutrition Value App' in response.data)
response = tester.get('/get_food_items', content_type="html/text")
self.assertTrue(b'Click to check the details of each food item' in response.data)
response = tester.get('/add_food_item', content_type="html/text")
self.assertTrue(b'Add the details for the food item you want to add and click the "Add" button' in response.data)
response = tester.get('/get_classification', content_type="html/text")
self.assertTrue(b'The following is a list of food classifications in this data set' in response.data)
response = tester.get('/add_class', content_type="html/text")
self.assertTrue(b'Add a Food Class' in response.data)
response = tester.get('/dashboard', content_type="html/text")
self.assertTrue(b'Dashboard' in response.data)
response = tester.get('/about', content_type="html/text")
self.assertTrue(b'About this App' in response.data)
response = tester.get('/contact', content_type="html/text")
self.assertTrue(b'Contact Us' in response.data)
if __name__ == "__main__":
unittest.main()