forked from sb-/OpenExchange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
42 lines (34 loc) · 1.21 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
import os
import app
import unittest
import tempfile
""" Just modified the Flask example unit test, need to write orderbook tests."""
class ExchangeTestCase(unittest.TestCase):
def setUp(self):
self.db_fd, app.app.config['DATABASE'] = tempfile.mkstemp()
app.app.config['TESTING'] = True
self.app = app.app.test_client()
app.init_db()
def tearDown(self):
os.close(self.db_fd)
os.unlink(app.app.config['DATABASE'])
def login(self, email, password):
return self.app.post('/login', data=dict(
email=email,
password=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 logout(self):
return self.app.get('/logout', follow_redirects=True)
if __name__ == '__main__':
unittest.main()