-
Notifications
You must be signed in to change notification settings - Fork 0
/
crudAppTests.py
43 lines (33 loc) · 1.08 KB
/
crudAppTests.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
#!/user/bin/python
import os
import unittest
import os
import unittest
import tempfile
import crudapp
# from flask_testing import TestCase
class User():
def __init__(self, id, username, ip, timestamp):
self.id = id
self.username = username
self.ip = ip
self.timestmap = timestamp
class crudAppTestCase(unittest.TestCase):
def setUp(self):
self.db_fd, crudapp.app.config['DATABASE'] = tempfile.mkstemp()
crudapp.app.config['TESTING'] = True
self.app = crudapp.app.test_client()
with crudapp.app.app_context():
crudapp.db.create_all()
def tearDown(self):
os.close(self.db_fd)
os.unlink(crudapp.app.config['DATABASE'])
def test_homepage(self):
rv = self.app.get('/')
assert b"Welcome to the world's greatest CRUD app" in rv.data
def create_new_user(self):
rv = self.app.post('/user/',
data=json.dumps(dict(username='max')),
content_type="application/json")
if __name__ == '__main__':
unittest.main()