Esempio n. 1
0
    def test_quote(self):
        """
        Validates/verifies that the quoting support is complete
        and correctly working. Uses a lot of languages to try
        to add complexity to the set of tests.
        """

        result = colony.quote("Hello World")
        self.assertEqual(result, "Hello%20World")

        result = colony.quote("Olá Mundo")
        self.assertEqual(result, "Ol%C3%A1%20Mundo")

        result = colony.quote("你好世界")
        self.assertEqual(result, "%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C")
Esempio n. 2
0
    def test_quote(self):
        """
        Validates/verifies that the quoting support is complete
        and correctly working. Uses a lot of languages to try
        to add complexity to the set of tests.
        """

        result = colony.quote("Hello World")
        self.assertEqual(result, "Hello%20World")

        result = colony.quote("Olá Mundo")
        self.assertEqual(result, "Ol%C3%A1%20Mundo")

        result = colony.quote("你好世界")
        self.assertEqual(result, "%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C")
Esempio n. 3
0
    def _redirect(self, request, target_path, status_code = 301, quote = True):
        """
        Redirects the given request to the target path.

        :type request: HttpRequest
        :param request: The http request to be handled.
        :type target_path: String
        :param target_path: The target path of the redirection.
        :type status_code: int
        :param status_code: The status code to be used.
        :type quote: bool
        :param quote: If the target path should be quoted.
        """

        # quotes the target path
        target_path_quoted = quote and colony.quote(target_path, "/") or target_path

        # sets the status code
        request.status_code = status_code

        # sets the location header (using the quoted target path)
        request.set_header(LOCATION_VALUE, target_path_quoted)