Ejemplo n.º 1
0
 def test_logged_in_users_can_access_tasks_page(self):
     response = self.app.get('tasks/')
     self.assertEqual(response.status_code, 200)
     self.assertIn(b'Add a new task:', response.data)
     logout(self)
     response2 = self.app.get('tasks/', follow_redirects=True)
     self.assertIn(b'You need to login first.', response2.data)
Ejemplo n.º 2
0
 def test_users_cannot_delete_tasks_that_are_not_created_by_them(self):
     self.app.get('tasks', follow_redirects=True)
     create_task(self)
     logout(self)
     create_user(self, 'Fletcher', '*****@*****.**', 'python101')
     login(self, 'Fletcher', 'python101')
     self.app.get('tasks/', follow_redirects=True)
     response = self.app.get("delete/1/", follow_redirects=True)
     self.assertIn(b'You can only delete tasks that belong to you.',
                   response.data)
Ejemplo n.º 3
0
 def test_admin_users_can_delete_tasks_that_are_not_created_by_them(self):
     self.app.get('tasks/', follow_redirects=True)
     create_task(self)
     logout(self)
     create_admin_user(self)
     login(self, 'AdminUser', 'allpowerful')
     self.app.get('tasks/', follow_redirects=True)
     response = self.app.get('delete/1/', follow_redirects=True)
     self.assertNotIn(b'You can only delete tasks that belong to you.',
                      response.data)
Ejemplo n.º 4
0
 def test_users_can_see_task_modify_links_for_tasks_created_by_them(self):
     login(self, 'Michael', 'python')
     self.app.get('tasks/', follow_redirects=True)
     create_task(self)
     logout(self)
     register(self, 'Fletcher', '*****@*****.**', 'python101',
              'python101')
     login(self, 'Fletcher', 'python101')
     self.app.get('tasks/', follow_redirects=True)
     response = create_task(self)
     self.assertIn(b'complete/2/', response.data)
     self.assertIn(b'complete/2/', response.data)
Ejemplo n.º 5
0
 def test_admin_users_can_see_task_modify_links_for_all_tasks(self):
     login(self, 'Michael', 'python')
     self.app.get('tasks/', follow_redirects=True)
     create_task(self)
     logout(self)
     create_admin_user(self)
     login(self, 'AdminUser', 'allpowerful')
     self.app.get('tasks/', follow_redirects=True)
     response = create_task(self)
     self.assertIn(b'complete/1/', response.data)
     self.assertIn(b'delete/1/', response.data)
     self.assertIn(b'complete/2/', response.data)
     self.assertIn(b'delete/2/', response.data)
Ejemplo n.º 6
0
 def test_logged_in_users_can_logout(self):
     login(self, 'Michael', 'python')
     response = logout(self)
     self.assertIn(b'Goodbye!', response.data)
Ejemplo n.º 7
0
 def test_invalid_form_data(self):
     logout(self)
     response = login(self, 'alert("alert box!");', 'foo')
     self.assertIn(b'Invalid username or password.', response.data)