-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
68 lines (47 loc) · 1.79 KB
/
tests.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
from server import app
from model import db, connect_to_db
import unittest
import test_seed_data
class serverTests(unittest.TestCase):
"""Tests for Picture This app."""
def setUp(self):
"""Code to run before every test."""
self.client = app.test_client() # test_client from Werkzeug library returns a "browser" to "run" app
app.config['TESTING'] = True
def test_homepage(self):
"""Does homepage load?"""
result = self.client.get("/")
self.assertEqual(result.status_code, 200)
self.assertIn(b"Welcome", result.data)
def test_my_board(self):
"""Does My Board page load?"""
result = self.client.get("/my_board")
self.assertEqual(result.status_code, 200)
self.assertIn(b"board", result.data)
def test_upload_page(self):
"""Does Upload page load?"""
result = self.client.get("/upload")
self.assertEqual(result.status_code, 200)
self.assertIn(b"upload", result.data)
class TestDb(unittest.TestCase):
"""Tests database"""
def setUp(self):
"""Code to run before every test."""
self.client = app.test_client()
app.config['TESTING'] = True
connect_to_db(app, db_uri='postgresql:///pt')
db.create_all()
test_seed_data.test_all()
####### ** see test_seed_data.py for test_data helper functions ** #######
def test_homepage(self):
"""Can I add everything to my db?"""
result = self.client.get('/')
self.assertEqual(result.status_code, 200)
self.assertIn(b"Welcome", result.data)
def tearDown(self):
"""Code to run after every test"""
db.session.remove()
db.drop_all()
db.engine.dispose()
if __name__ == "__main__":
unittest.main(verbosity=2)