MCPcopy
hub / github.com/django/django / test_full_request_response_cycle

Method test_full_request_response_cycle

tests/messages_tests/base.py:147–164  ·  view source on GitHub ↗

With the message middleware enabled, messages are properly stored and retrieved across the full request/redirect/response cycle.

(self)

Source from the content-addressed store, hash-verified

145
146 @override_settings(MESSAGE_LEVEL=constants.DEBUG)
147 def test_full_request_response_cycle(self):
148 """
149 With the message middleware enabled, messages are properly stored and
150 retrieved across the full request/redirect/response cycle.
151 """
152 data = {
153 "messages": ["Test message %d" % x for x in range(5)],
154 }
155 show_url = reverse("show_message")
156 for level in ("debug", "info", "success", "warning", "error"):
157 add_url = reverse("add_message", args=(level,))
158 response = self.client.post(add_url, data, follow=True)
159 self.assertRedirects(response, show_url)
160 self.assertIn("messages", response.context)
161 messages = [Message(self.levels[level], msg) for msg in data["messages"]]
162 self.assertEqual(list(response.context["messages"]), messages)
163 for msg in data["messages"]:
164 self.assertContains(response, msg)
165
166 @override_settings(MESSAGE_LEVEL=constants.DEBUG)
167 def test_with_template_response(self):

Callers

nothing calls this directly

Calls 5

reverseFunction · 0.90
MessageClass · 0.90
assertRedirectsMethod · 0.80
assertContainsMethod · 0.80
postMethod · 0.45

Tested by

no test coverage detected