-
Notifications
You must be signed in to change notification settings - Fork 4
/
app_tests.py
66 lines (60 loc) · 2.44 KB
/
app_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
import os
from database.database import init_db
import app
import unittest
import tempfile
class AppTestCase(unittest.TestCase):
def setUp(self):
self.db_fd, app.app.config['DATABASE'] = tempfile.mkstemp()
app.app.config['TESTING'] = True
app.app.config['WTF_CSRF_ENABLED'] = False
self.app = app.app.test_client()
with app.app.app_context():
init_db()
def tearDown(self):
os.close(self.db_fd)
os.unlink(app.app.config['DATABASE'])
# def test_without_login(self):
# rv_root = self.app.get("/")
# assert b'<body class="loginbody"' in rv_root.data
# rv_lp = self.app.get("/listofprojects", follow_redirects=True)
# assert b'<body class="loginbody"' in rv_lp.data
# rv_fac = self.app.get("/faculty", follow_redirects=True)
# assert b'<body class="loginbody"' in rv_fac.data
# rv_stud = self.app.get("/student", follow_redirects=True)
# assert b'<body class="loginbody"' in rv_stud.data
#
# def test_signup(self):
# rv = self.app.post("/signup", data=dict(
# first_name="testFirst",
# last_name="testLast",
# email="test@colorado.edu",
# password="testpwd"
# ), follow_redirects=True)
# if b'Create your account' not in rv.data:
# assert b'Whether helping develop new diagnostic techniques' in rv.data
#
# def test_login(self):
# return self.app.post("/login", data=dict(
# useremail="test@colorado.edu",
# password="testpwd"
# ), follow_redirects=True)
#
# def test_home_page(self):
# self.test_signup()
# rv_login = self.test_login()
# assert b'Whether helping develop new diagnostic techniques' in rv_login.data
# rv = self.app.get("/")
# assert b'Whether helping develop new diagnostic techniques' in rv.data
#
# def test_post_request(self):
# self.test_signup()
# rv_login = self.test_login()
# assert b'Whether helping develop new diagnostic techniques' in rv_login.data
# self.app.post("/listofprojects",
# data=dict(facultyFirstName="test_db_first_name", facultyLastName="test_db_last_name"))
# rv = self.app.get("/listofprojects")
# assert b'test_db_first_name' in rv.data
# assert b'test_db_last_name' in rv.data
if __name__ == '__main__':
unittest.main()