User register unittest

Public user registration unittest is implimented with this commit
This commit is contained in:
kelepirci 2016-07-30 17:28:31 +03:00
parent be52ca5ddf
commit c8c5d627bd
1 changed files with 27 additions and 6 deletions

View File

@ -32,6 +32,26 @@ class ViewFunctionsTestCase(unittest.TestCase):
db.drop_all()
self.app_context.pop()
# test user registration
def user_register(self, email, username, full_name, password, password2, terms):
return self.app_test_client.post('/auth/register',
data=dict(
email=email,
username=username,
full_name=full_name,
password=password,
password2=password2,
terms=terms), follow_redirects=True)
def test_user_registration(self):
rv = self.user_register('test2@dash-stack.org',
'test2',
'Dash Stack the Second',
'test2',
'test2',
True)
assert 'You can now login.' in rv.data
# user login function
def login(self, email, password):
return self.app_test_client.post('/auth/login',
@ -47,12 +67,13 @@ class ViewFunctionsTestCase(unittest.TestCase):
def test_login_logout(self):
rv = self.login('test@dash-stack.org', 'test')
assert 'Dash Stack - Web Developer' in rv.data
#rv = self.logout()
#assert 'You were logged out' in rv.data
#rv = self.login('testx@dash-stack.org', 'test')
#assert 'Invalid username' in rv.data
#rv = self.login('test@dash-stack.org', 'testx')
#assert 'Invalid password' in rv.data
rv = self.logout()
assert 'You have been logged out.' in rv.data
rv = self.login('testx@dash-stack.org', 'test')
assert 'Invalid username or password.' in rv.data
rv = self.login('test@dash-stack.org', 'testx')
assert 'Invalid username or password.' in rv.data
if __name__ == '__main__':
unittest.main()