-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing_server.py
64 lines (36 loc) · 1.5 KB
/
testing_server.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
import server
import unittest
import os
from model import database_connect, database
class IntegrationTests(unittest.TestCase):
"""Tests for the Flask server"""
#setup to reduce repetition between methods
@classmethod
def setUpClass(cls):
os.system("dropdb testdb")
os.system("createdb testdb")
# from testing 1 lecture- printing Flask errors
server.app.config['TESTING'] = True
#connecting to a test database
#syntax of database_connect function is such that name of database without postgresql:/// should be the second param
database_connect(server.app, "testdb")
database.create_all()
cls.client = server.app.test_client()
def test_homepage(self):
"""Testing for homepage success"""
output = self.client.get('/')
self.assertEqual(output.status_code,200)
self.assertIn(b'Welcome to Paws For Alarm', output.data)
def test_faq(self):
"""Testing for FAQ page success"""
output = self.client.get('/faq')
self.assertEqual(output.status_code,200)
self.assertIn(b'FAQ', output.data)
def test_animalpage(self):
"""Testing for animal list page success"""
output = self.client.get('/animals')
self.assertEqual(output.status_code,200)
self.assertIn(b'Animals with Euthanasia Risk Or In Need of Foster', output.data)
if __name__ == "__main__":
import unittest
unittest.main()