Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
 def test_users_can_add_tasks(self):
     self.app.get('tasks/', follow_redirects=True)
     response = create_task(self)
     self.assertIn(b'New entry was successfully posted. Thanks',
                   response.data)
     self.app.get('tasks/', follow_redirects=True)
     response = self.app.post('add/',
                              data=dict(name='Go to the bank',
                                        due_date='',
                                        priority='1',
                                        posted_date='02/05/2014',
                                        status='1'),
                              follow_redirects=True)
     self.assertIn(b'This field is required.', response.data)
Exemplo n.º 6
0
 def test_users_can_delete_tasks(self):
     self.app.get('tasks/', follow_redirects=True)
     create_task(self)
     response = self.app.get("delete/1/", follow_redirects=True)
     self.assertIn(b'The task was deleted.', response.data)
Exemplo n.º 7
0
 def test_users_can_complete_tasks(self):
     self.app.get('tasks/', follow_redirects=True)
     create_task(self)
     response = self.app.get("complete/1/", follow_redirects=True)
     self.assertIn(b'The task is complete. Nice', response.data)