示例#1
0
    def test_options_post(self):
        """
        Try to view options as anonymous.
        """
        self.test_options_user()
        self.client.login(username=self.username, password=self.password)
        response = self.client.post(
            reverse('planet:options'),
            {
                'number_initially_displayed': "11",
                'max_entries_saved': "101",
                'number_additionally_displayed': "9",
                'submit': "Submit",
            },
        )
        self.assertEquals(response.status_code, 302)
        self.assertNumQueries(1)

        request = self.factory.get(reverse('planet:options'), {
            'number_initially_displayed': "11",
        })
        request.user = self.user
        response = OptionsView.as_view()(request)

        self.assertEquals(response.status_code, 200)
        self.assertNumQueries(1)
        """
        .. todo:: This should actually be '11', after
        we updated the value above.
        """
        options = Options.objects.get(user=self.user)
        self.assertEqual(options.user, self.user)
示例#2
0
 def test_options_user(self):
     """
     Try to view options as anonymous.
     """
     request = self.factory.get(reverse('planet:options'))
     request.user = self.user
     response = OptionsView.as_view()(request)
     self.assertEquals(response.status_code, 200)
示例#3
0
 def test_options_user(self):
     """
     Try to view options as anonymous.
     """
     request = self.factory.get(reverse('planet:options'))
     request.user = self.user
     response = OptionsView.as_view()(request)
     self.assertEquals(response.status_code, 200)
示例#4
0
    def test_options_post(self):
        """
        Try to view options as anonymous.
        """
        self.test_options_user()
        self.client.login(username=self.username, password=self.password)
        response = self.client.post(
            reverse('planet:options'),
            {
                'number_initially_displayed': "11",
                'max_entries_saved': "101",
                'number_additionally_displayed': "9",
                'submit': "Submit",
            },
        )
        self.assertEquals(response.status_code, 302)
        self.assertNumQueries(1)

        request = self.factory.get(
            reverse('planet:options'),
            {
                'number_initially_displayed': "11",
            }
        )
        request.user = self.user
        response = OptionsView.as_view()(request)

        self.assertEquals(response.status_code, 200)
        self.assertNumQueries(1)

        """
        .. todo:: This should actually be '11', after
        we updated the value above.
        """
        options = Options.objects.get(user=self.user)
        self.assertEqual(options.user, self.user)