def test_registering_user(self): """Test that a user cannot be registered twice.""" new_user = self.app new_user.create_user() client = app.test_client(self) response = client.post('/login', follow_redirects=True) self.assertEqual(response.status_code, 200)
def test_invalid_credentials_redirects_to_login(self): """Users need valid credentials""" tester = app.test_client(self) response = tester.post('/login', data=dict(email='*****@*****.**', password='******'), follow_redirects=True) self.assertEqual(response.status_code, 200)
def test_signup_existing_user_redirects_to_login(self): """Users get redirected to login if they have a/c""" tester = app.test_client(self) response = tester.post('/signup', data=dict(email='*****@*****.**', usrname='leo', password='******'), follow_redirects=True) self.assertEqual(response.status_code, 200)
def setUp(self): """ Setup a bucketlist """ User.users = {1: {'*****@*****.**', 'leo', 'pwd'}} self.app = Bucketlist('Hiking', 'Go for hiking') Bucketlist.bucketlists = {} self.client = app.test_client(self) # Set some default bucketlist data self.bucketlist_data = { 1: { 'user_id': 1, 'name': 'Hiking', 'description': 'Go for hiking' } }
def test_index(self): """ Initial test to ensure flask was setup correctly """ tester = app.test_client( self) # You can use self.app in place of tester response = tester.get('/', content_type='html/text') self.assertEqual(response.status_code, 200)
def test_show_activities_without_login_redirects(self): """Users need valid credentials""" User.users = {} tester = app.test_client(self) response = tester.post('/show_bucketlists', follow_redirects=True) self.assertEqual(response.status_code, 200)
def test_login_to_bucketlists(self): """ Ensure signup redirects to login """ tester = app.test_client(self) response = tester.post('/login', follow_redirects=True) self.assertEqual(response.status_code, 200)
def test_logout_redirects_to_homepage(self): """ Ensure logout redirects to hp """ tester = app.test_client(self) response = tester.get('/logout', follow_redirects=True) self.assertEqual(response.status_code, 200)
def test_bucketlists_dashboard_without_login_redirects(self): """Users need valid credentials""" tester = app.test_client(self) response = tester.get('/show_bucketlists', follow_redirects=True) self.assertEqual(response.status_code, 200)