forked from sb-/OpenExchange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
54 lines (43 loc) · 1.75 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
import os
import unittest
import tempfile
from app import app
from app.database import init_db
class ExchangeTestCase(unittest.TestCase):
""" Just modified the Flask example unit test, need to write orderbook tests."""
def setUp(self):
self.db_fd, app.config['DATABASE'] = tempfile.mkstemp()
app.config['TESTING'] = True
self.app = app.test_client()
init_db()
def tearDown(self):
os.close(self.db_fd)
os.unlink(app.config['DATABASE'])
def login(self, email, password):
return self.app.post('/login', data=dict(
email=email,
password=password
), follow_redirects=True)
#def register(self, name, email, password, confirm_password):
# return self.app.post('/register', data = dict(name=name,email=email,password=password,confirm_password=confirm_password), follow_redirects=True)
def logout(self):
return self.app.get('/logout', follow_redirects=True)
def test_login_logout(self):
rv = self.login('[email protected]', 'shit')
assert 'Logged in!' in rv.data
rv = self.logout()
assert 'Successfully logged out!' in rv.data
rv = self.login('adminx', 'default')
assert 'Please check your email and username.' in rv.data
rv = self.login('admin', 'defaultx')
assert 'Please check your email and username.' in rv.data
"""def test_register(self):
rv = self.register('new acc', [email protected]', 'testpass', 'testpass')
assert 'Successfully registered' in rv.data
rv = self.login()
assert 'Please confirm' in rv.data
"""
def logout(self):
return self.app.get('/logout', follow_redirects=True)
if __name__ == '__main__':
unittest.main()