-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.py
44 lines (31 loc) · 1022 Bytes
/
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
import app
import unittest
from models import User
from database import db_session, clear_db
class BaseTestCase(unittest.TestCase):
def setUp(self):
app.setup('config/test_config.py')
def tearDown(self):
clear_db()
class EmailExistsTestCase(BaseTestCase):
def insert_email_fixture(self):
username = 'test'
firstname = 'test'
lastname = 'test'
email = '[email protected]'
phone = '123-123-1234'
salt = 'salt'
password = app.get_hash('test', salt)
user = User(username, firstname, lastname, email,
phone, password, salt)
db_session.add(user)
db_session.commit()
def test_email_does_not_exists(self):
actual = app.email_exists("[email protected]")
self.assertFalse(actual)
def test_email_exists(self):
self.insert_email_fixture()
actual = app.email_exists("[email protected]")
self.assertTrue(actual)
if __name__ == '__main__':
unittest.main()