Пример #1
0
    def test_get_wsgi_application(self):
        """
        Verify that ``get_wsgi_application`` returns a functioning WSGI callable.
        """
        application = get_wsgi_application()
        environ = RequestFactory()._base_environ(
            PATH_INFO="/info",
            CONTENT_TYPE="text/html; charset=utf-8",
            REQUEST_METHOD="GET")
        response_data = {}

        def start_response(status, headers):
            response_data["status"] = status
            response_data["headers"] = headers

        response = application(environ, start_response)
        self.assertEqual(response_data["status"], "500 Internal Server Error")
        self.assertEqual(response_data["headers"],
                         [('Content-Type', 'text/html; charset=utf-8')])
        self.assertEqual(
            bytes(response),
            b'Content-Type: text/html; charset=utf-8\r\n\r\n{\n   '
            b' "badRequest": {\n       '
            b' "message": "Server Database does not contain information server", \n '
            b'       "code": 500\n    }\n}')
Пример #2
0
    def test_get_wsgi_application(self):
        """
        Verify that ``get_wsgi_application`` returns a functioning WSGI callable.
        """
        application = get_wsgi_application()
        environ = RequestFactory()._base_environ(
            PATH_INFO="/info",
            CONTENT_TYPE="text/html; charset=utf-8",
            REQUEST_METHOD="GET"
            )
        response_data = {}

        def start_response(status, headers):
            response_data["status"] = status
            response_data["headers"] = headers
        response = application(environ, start_response)
        self.assertEqual(response_data["status"], "500 Internal Server Error")
        self.assertEqual(
            response_data["headers"],
            [('Content-Type', 'text/html; charset=utf-8')])
        self.assertEqual(
            bytes(response),
            b'Content-Type: text/html; charset=utf-8\r\n\r\n{\n   '
            b' "badRequest": {\n       '
            b' "message": "Server Database does not contain information server", \n '
            b'       "code": 500\n    }\n}')
Пример #3
0
    def test_get_wsgi_application(self):
        """
        Verify that ``get_wsgi_application`` returns a functioning WSGI callable.
        """
        application = get_wsgi_application()
        environ = RequestFactory()._base_environ(
            PATH_INFO="/helloworld",
            CONTENT_TYPE="text/html; charset=utf-8",
            REQUEST_METHOD="GET"
            )
        response_data = {}

        def start_response(status, headers):
            response_data["status"] = status
            response_data["headers"] = headers
        response = application(environ, start_response)
        self.assertEqual(response_data["status"], "200 OK")
        self.assertEqual(
            response_data["headers"],
            [('Content-Type', 'text/html; charset=utf-8')])
        self.assertEqual(
            bytes(response),
            b"Content-Type: text/html; charset=utf-8\r\n\r\nIt Works")