MCPcopy
hub / github.com/django/django / test_xview_func

Method test_xview_func

tests/admin_docs/test_middleware.py:9–25  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7
8class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase):
9 def test_xview_func(self):
10 user = User.objects.get(username="super")
11 response = self.client.head("/xview/func/")
12 self.assertNotIn("X-View", response)
13 self.client.force_login(self.superuser)
14 response = self.client.head("/xview/func/")
15 self.assertIn("X-View", response)
16 self.assertEqual(response.headers["X-View"], "admin_docs.views.xview")
17 user.is_staff = False
18 user.save()
19 response = self.client.head("/xview/func/")
20 self.assertNotIn("X-View", response)
21 user.is_staff = True
22 user.is_active = False
23 user.save()
24 response = self.client.head("/xview/func/")
25 self.assertNotIn("X-View", response)
26
27 def test_xview_class(self):
28 user = User.objects.get(username="super")

Callers

nothing calls this directly

Calls 4

force_loginMethod · 0.80
getMethod · 0.45
headMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected