예제 #1
0
 def test_invalid_user_registration_duplicate_username(self):
     response = register(self.app, 'testuser', '*****@*****.**',
                         'FlaskIsAwesome', 'FlaskIsAwesome', True)
     self.assertEqual(response.status_code, 200)
     response = register(self.app, 'testuser', '*****@*****.**',
                         'FlaskIsAwesome', 'FlaskIsAwesome', True)
     self.assertIn(b'Please use a different username.', response.data)
예제 #2
0
 def test_main_page(self):
     with self.app as a:
         register(self.app, 'test123', '*****@*****.**', 'cat', 'cat',
                  True)
         login(a, 'test123', 'cat', True)
         response = self.app.get('/', follow_redirects=True)
         self.assertEqual(response.status_code, 200)
예제 #3
0
 def setUp(self):
     app = create_app(TestConfig)
     self.app_context = app.app_context()
     self.app_context.push()
     self.app = app.test_client()
     db.create_all()
     register(self.app, 'test123', '*****@*****.**', 'cat', 'cat', True)
예제 #4
0
 def test_invalid_user_registration_different_passwords(self):
     response = register(self.app, 'testuser', '*****@*****.**',
                         'FlaskIsAwesome', 'FlaskIsNotAwesome', True)
     self.assertIn(b'Field must be equal to password.', response.data)
예제 #5
0
 def test_valid_user_registration_redirect(self):
     response = register(self.app, 'testuser', '*****@*****.**',
                         'FlaskIsAwesome', 'FlaskIsAwesome', False)
     self.assertEqual('http://localhost/auth/login', response.location)
예제 #6
0
 def test_valid_user_registration(self):
     response = register(self.app, 'testuser', '*****@*****.**',
                         'FlaskIsAwesome', 'FlaskIsAwesome', True)
     self.assertEqual(200, response.status_code)
     self.assertIn(b'Congratulations, you are now a registered user!',
                   response.data)