Example #1
0
 def assert_django_messages_present(self, message, request, response):
     middleware = AjaxMiddleware()
     processed_response = middleware.process_template_response(request,
                                                               response)
     assert_that(processed_response.serializable_content,
                 has_key("django_messages"))
     assert_that(processed_response.serializable_content["django_messages"][0],
                 has_entry("message", equal_to(message)))
Example #2
0
    def test_middleware_appends_messages(self):
        request = HttpRequest()
        request.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
        SessionMiddleware().process_request(request)
        MessageMiddleware().process_request(request)

        message = "Hello. Yes. This is dog"
        messages.info(request, message)

        response = JsonResponse()
        middleware = AjaxMiddleware()
        processed_response = middleware.process_template_response(request, response)

        assert_that(processed_response.dict_content["django_messages"][0], has_entry("message", equal_to(message)))
Example #3
0
    def test_middleware_appends_messages(self):
        request = HttpRequest()
        request.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
        SessionMiddleware().process_request(request)
        MessageMiddleware().process_request(request)

        message = "Hello. Yes. This is dog"
        messages.info(request, message)

        response = JsonResponse()
        middleware = AjaxMiddleware()
        processed_response = middleware.process_template_response(
            request, response)

        assert_that(processed_response.dict_content["django_messages"][0],
                    has_entry("message", equal_to(message)))