예제 #1
0
 def test_POST_that_moves_from_actionlist_returns_to_actionlist(self):
     self.assertEqual(self.action.project,
         models.get_user_action_project(alice))
     response = self.post_request(alice, {'project': self.project.pk,
         'text': self.action.text}, pk=self.action.pk)
     self.assertEqual(response.url, reverse('projects:project',
         kwargs={'pk': models.get_user_action_project(alice).pk}))
예제 #2
0
    def test_POST_request_can_remove_project(self):
        self.action.project = self.project
        self.action.save()
        self.assertIsNotNone(self.action.project)

        response = self.post_request(alice,
            {'project': models.get_user_action_project(alice).pk,
            'text': self.action.text}, pk=self.action.pk)

        self.action.refresh_from_db()
        self.assertEqual(self.action.project,
            models.get_user_action_project(alice))
예제 #3
0
    def test_permission_denied_is_called_with_exception_argument(self,
        mock_permission_denied):
        project = models.get_user_action_project(alice)
        request = self.factory.get(self.url)
        request.user = alice
        response = self.view(request, self.url, pk=project.pk)

        mock_permission_denied.assert_called_once_with(request, None)
예제 #4
0
 def test_403_error_gets_dummy_exception(self, mock_permission_denied):
     request = self.factory.post(self.url)
     request.user = alice
     self.view(request, self.url,
         pk=models.get_user_action_project(alice).pk)
     mock_permission_denied.assert_called_once_with(request, None)
예제 #5
0
 def test_returns_403_when_deleting_users_action_project_with_post(self):
     response = self.post_request(alice,
         pk=models.get_user_action_project(alice).pk)
     self.assertEqual(response.status_code, 403)
예제 #6
0
 def test_returns_403_when_trying_to_edit_action_project_with_post(self):
     project = models.get_user_action_project(alice)
     response = self.post_request(alice, pk=project.pk)
     self.assertEqual(response.status_code, 403)
예제 #7
0
 def test_notifies_when_project_is_users_action_project(self):
     project = models.get_user_action_project(alice)
     response = self.get_request(alice, pk=project.pk)
     self.assertTrue(response.context_data['protected'])
예제 #8
0
 def test_POST_redirects_to_action_list_for_non_project_actions(self):
     response = self.post_request(alice, pk=self.item.pk)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response.url, reverse('projects:project',
         kwargs={'pk': models.get_user_action_project(alice).pk}))