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)
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)
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)
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))
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)
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.")
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.')