예제 #1
0
    def test_get_context_data(self):
        """Test getting context data."""
        UserFactory.create_batch(2, **{"is_superuser": True})
        UserFactory.create_batch(2, **{"is_superuser": False})
        view = ManageSuperusers()
        context = view.get_context_data()

        self.assertEqual(len(context.get("superusers")), 2)
예제 #2
0
    def test_get_context_data(self):
        """Test getting context data."""
        UserFactory.create_batch(2, **{'is_superuser': True})
        UserFactory.create_batch(2, **{'is_superuser': False})
        view = ManageSuperusers()
        context = view.get_context_data()

        self.assertEqual(len(context.get('superusers')), 2)
예제 #3
0
    def test_get_with_superuser(self):
        """Test GET with superuser."""
        view = ManageSuperusers.as_view()
        self.request.user = UserFactory.create(**{"is_superuser": True})
        response = view(self.request).render()

        self.assertEqual(response.status_code, 200)
예제 #4
0
    def test_get_with_anonymous(self):
        """Test GET with anonymous user."""
        view = ManageSuperusers.as_view()
        self.request.user = AnonymousUser()
        response = view(self.request)

        self.assertTrue(isinstance(response, HttpResponseRedirect))
예제 #5
0
    def test_get_with_superuser(self):
        """Test GET with superuser."""
        view = ManageSuperusers.as_view()
        self.request.user = UserFactory.create(**{'is_superuser': True})
        response = view(self.request).render()

        self.assertEqual(response.status_code, 200)
예제 #6
0
    def test_get_with_anonymous(self):
        """Test GET with anonymous user."""
        view = ManageSuperusers.as_view()
        self.request.user = AnonymousUser()
        response = view(self.request)

        self.assertTrue(isinstance(response, HttpResponseRedirect))
예제 #7
0
    def test_get_with_user(self):
        """Test GET with user."""
        view = ManageSuperusers.as_view()
        self.request.user = UserFactory.create(**{"is_superuser": False})
        response = view(self.request).render()

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "No rights to access superuser tools.")
예제 #8
0
    def test_get_with_user(self):
        """Test GET with user."""
        view = ManageSuperusers.as_view()
        self.request.user = UserFactory.create(**{'is_superuser': False})
        response = view(self.request).render()

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'No rights to access superuser tools.')