예제 #1
0
    def test_changelist_template_context(self):
        poll = PollFactory()
        url = reverse('admin:polls_poll_change', args=(poll.pk, ))

        response = self.client.get(url)
        self.assertIn('objectactions', response.context_data)
        self.assertIn('tools_view_name', response.context_data)
        self.assertIn('foo', response.context_data)
예제 #2
0
    def test_redirect_back_from_secondary_admin(self):
        poll = PollFactory()
        admin_change_url = reverse('admin:polls_poll_change',
                                   args=(poll.pk, ),
                                   current_app='support')
        action_url = '/support/polls/poll/1/actions/question_mark/'
        self.assertTrue(admin_change_url.startswith('/support/'))

        response = self.client.get(action_url)
        self.assertRedirects(response, admin_change_url)
예제 #3
0
    def test_get_changelist_can_remove_action(self):
        poll = PollFactory.create()
        self.assertFalse(poll.question.endswith('?'))
        admin_change_url = reverse('admin:polls_poll_change', args=(poll.pk,))
        action_url = '/admin/polls/poll/1/actions/question_mark/'

        # button is in the admin
        response = self.client.get(admin_change_url)
        self.assertIn(action_url, response.rendered_content)

        response = self.client.get(action_url)  # Click on the button
        self.assertRedirects(response, admin_change_url)

        # button is not in the admin anymore
        response = self.client.get(admin_change_url)
        self.assertNotIn(action_url, response.rendered_content)
예제 #4
0
    def test_get_changelist_can_remove_action(self):
        poll = PollFactory.create()
        self.assertFalse(poll.question.endswith("?"))
        admin_change_url = reverse("admin:polls_poll_change", args=(poll.pk,))
        action_url = "/admin/polls/poll/1/actions/question_mark/"

        # button is in the admin
        response = self.client.get(admin_change_url)
        self.assertIn(action_url, response.rendered_content)

        response = self.client.get(action_url)  # Click on the button
        self.assertRedirects(response, admin_change_url)

        # button is not in the admin anymore
        response = self.client.get(admin_change_url)
        self.assertNotIn(action_url, response.rendered_content)