-
Notifications
You must be signed in to change notification settings - Fork 17
/
test.py
45 lines (33 loc) · 1.02 KB
/
test.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
import os
os.environ['WEB_ENV'] = 'test'
import unittest
import web
from web.browser import AppBrowser
import app
import seed
import model as m
b = AppBrowser(app.app)
class AppTest(unittest.TestCase):
def setUp(self):
seed.init()
# Add global setup here
pass
class TestIntegration(AppTest):
def test_index(self):
b.open('/')
self.assertEqual(200, b.status)
class TestUser(AppTest):
def test_password_is_crypted(self):
u = m.User.create(email='[email protected]',
password='test123')
self.assertIsNotNone(u.salt)
self.assertIsNotNone(u.crypted_password)
self.assertTrue(u.authenticate('test123'))
self.assertFalse(u.authenticate('test1234'))
u.update_fields(password='testy')
self.assertIsNotNone(u.salt)
self.assertIsNotNone(u.crypted_password)
self.assertTrue(u.authenticate('testy'))
self.assertFalse(u.authenticate('test123'))
if __name__ == '__main__':
unittest.main()