-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
37 lines (29 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
import unittest
from flask.ext.testing import TestCase
from book import app,db
from book.models import User
class BaseTestCase(TestCase):
def setUp(self):
DEBUG = True
TESTING = True
WTF_CSRF_ENABLED = False
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
db.create_all()
def tearDown(self):
db.session.remove()
db.drop_all()
def add_user(self):
db.session.add(User("admin root","adin", "ad@min.com", "admin"))
db.session.commit()
def test_index(self):
response = self.client.get('/login',content_type='html/text')
self.assertEqual(response.status_code, 200)
def test_avatar(self):
# create a user
u = User(fullname="admin root",username="adin",email="ad@min.com",password="admin")
avatar = u.avatar(128)
expected = 'http://www.gravatar.com/avatar/' + \
'd4c74594d841139328695756648b6bd6'
assert avatar[0:len(expected)] == expected
if __name__ == 'main':
unittest.main()