Example #1
0
    def setUp(self):
        "Helps set up our environment"
        self.app = app.test_client()
        app.config['WTF_CSRF_ENABLED'] = False

        self.app.testing = True
        self.user = User('etwin', '*****@*****.**', 'etwin')
Example #2
0
 def test_recipes_add_page_contains_right_content_for_logged_in_users(self):
     "Tests if the recipe_add page contains the right content"
     with app.test_client(self) as client:
         client.post('/register',
                     data=dict(username="******",
                               email="*****@*****.**",
                               password="******",
                               password2="etwin"))
         client.post('/login',
                     data=dict(username="******", password="******"))
         response = client.get('/recipes_add', content_type='html/text')
         self.assertIn(b'Create a new Recipe', response.data)
Example #3
0
 def test_one_user_exists_for_newly_user_signed_in_user(self):
     "Tests user exixsts after sign up and login"
     with app.test_client(self) as client:
         client.post('/register',
                     data=dict(username="******",
                               email="*****@*****.**",
                               password="******",
                               password2="etwin"))
         client.post('/login',
                     data=dict(username="******", password="******"))
         user = session["users"]
         self.assertEqual(len(user), 1)
Example #4
0
 def test_logout_page_requires_login(self):
     "Test User is logged to access login page"
     with app.test_client(self) as client:
         client.post('/register',
                     data=dict(username="******",
                               email="*****@*****.**",
                               password="******",
                               password2="etwin"))
         client.post('/login',
                     data=dict(username="******", password="******"))
         response = client.get('/logout', follow_redirects=True)
         self.assertEqual(response.status_code, 200)
Example #5
0
 def test_category_create_page_contains_right_content(self):
     "Tests if the category_create page contains the right content"
     with app.test_client(self) as client:
         client.post('/register',
                     data=dict(username="******",
                               email="*****@*****.**",
                               password="******",
                               password2="etwin"))
         client.post('/login',
                     data=dict(username="******", password="******"))
         response = client.get('/category_add', content_type='html/text')
         self.assertIn(b'Create a new Category', response.data)
Example #6
0
 def test_no_category_for_new_user(self):
     "Tests no categories for a new user"
     with app.test_client(self) as client:
         client.post('/register',
                     data=dict(username="******",
                               email="*****@*****.**",
                               password="******",
                               password2="etwin"))
         client.post('/login',
                     data=dict(username="******", password="******"))
         response = client.get('/category', content_type="html/text")
         categories = self.user.user_categories
         self.assertEqual(len(categories), 0)
         self.assertIn(b'No Categories Added yet', response.data)
Example #7
0
 def test_recipes_add_page_doesnot_load_for_guest_users(self):
     "tests to see that the recipe_add page loads correctly"
     with app.test_client(self) as client:
         response = client.get('/recipes_add', content_type='html/text')
         self.assertEqual(response.status_code, 302)
Example #8
0
 def test_recipes_page_doesnot_load_page_for_guest_users(self):
     "tests to see that the recipes page loads correctly"
     tester = app.test_client(self)
     response = tester.get('/recipes', content_type='html/text')
     self.assertEqual(response.status_code, 302)
Example #9
0
 def test_login_page_contains_right_content(self):
     "Tests if the login page contains the right content"
     tester = app.test_client(self)
     response = tester.get('/login', content_type='html/text')
     self.assertIn(b'Please Login to continue', response.data)
Example #10
0
 def test_login_page_loads(self):
     "tests to see that the login page loads correctly"
     tester = app.test_client(self)
     response = tester.get('/login', content_type='html/text')
     self.assertEqual(response.status_code, 200)
Example #11
0
 def test_register_page_contains_right_content(self):
     "Tests if the register page contains the right content"
     tester = app.test_client(self)
     response = tester.get('/register', content_type='html/text')
     self.assertIn(b'Please Register to continue', response.data)
Example #12
0
 def test_index_page_contains_right_content(self):
     "Tests if the index page contains the right content"
     tester = app.test_client(self)
     response = tester.get('/', content_type='html/text')
     self.assertIn(b'Are you into preparing your food?', response.data)
Example #13
0
 def test_guest_user_cannot_access_logout_page(self):
     "Tests logout page is accessed by only logged in users"
     with app.test_client(self) as client:
         response = client.get('/logout', content_type='html/text')
         self.assertEqual(response.status_code, 302)
Example #14
0
 def test_index_page_loads_properly(self):
     "Tests if the index page loads properly"
     tester = app.test_client(self)
     response = tester.get('/', content_type='html/text')
     self.assertEqual(response.status_code, 200)