Пример #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.')