def contact(request): messages = MessagesSystem(request) if request.method == "POST": send_contact_email(request) return redirect("main_page:contact") return render( request, "main_page/contact.html", { "messages": messages.pop_contact(), "site_key": settings.RECAPTCHA_SITE_KEY })
def test_pop_contact_messages(self): self.request.session.update({"contact_messages": ["test"]}) messages_system = MessagesSystem(self.request) message = messages_system.pop_contact() self.assertEqual(self.request.session.get("contact_messages"), []) self.assertEqual(message, ["test"])