Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def test_user_invalid_credentials(self):
     response = login(self.app,
                      'invalihhhhd',
                      'abc123',
                      follow_redirects=True)
     self.assertIn(b'Invalid username or password', response.data)
     response = login(self.app, 'tester', 'abc1234', follow_redirects=True)
     self.assertIn(b'Invalid username or password', response.data)
Ejemplo n.º 3
0
 def test_user_login(self):
     user = User(username='******', email='*****@*****.**')
     user.set_password('abc123')
     db.session.add(user)
     db.session.commit()
     response = login(self.app, 'tester', 'abc123', follow_redirects=True)
     self.assertEqual(200, response.status_code)
     response = login(self.app, 'invalid', 'abc123', follow_redirects=False)
     self.assertEqual('http://localhost/index', response.location)
Ejemplo n.º 4
0
 def test_index(self):
     with self.app as a:
         login(a, 'test123', 'cat', True)
         response = self.app.get('index')
         self.assertEqual(200, response.status_code)
         self.assertIn(b'Hello, test123!', response.data)
Ejemplo n.º 5
0
 def test_valid_recipe_added(self):
     with self.app:
         login(self.app, 'test123', 'cat', True)
         response = add_recipe(self.app, submitted_by_user_id=1, follow_redirects=True)
         self.assertEqual(200, response.status_code)