示例#1
0
 def url_path_without_trailing_slash(self) -> None:
     self.environment["SERVER_NAME"] = "www.example.com"
     self.environment["PATH_INFO"] = "/abc/def"
     request = Request(self.environment)
     see_other(request, self.start_response, "foo/bar")
     self.start_response.assert_header_equals(
         "Location", "http://www.example.com/abc/foo/bar")
示例#2
0
 def extra_headers(self) -> None:
     request = Request(self.environment)
     see_other(
         request,
         self.start_response,
         "foo",
         extra_headers=[("X-Foo", "Bar")],
     )
     self.start_response.assert_header_equals("X-Foo", "Bar")
示例#3
0
 def headers(self) -> None:
     self.environment["SERVER_NAME"] = "www.example.com"
     request = Request(self.environment)
     see_other(request, self.start_response, "/foo/bar")
     self.start_response.assert_status(HTTPStatus.SEE_OTHER)
     self.start_response.assert_header_equals("Content-Type",
                                              "text/html; charset=utf-8")
     self.start_response.assert_header_equals(
         "Location", "http://www.example.com/foo/bar")
示例#4
0
 def html(self) -> None:
     request = Request(self.environment)
     response = see_other(request, self.start_response, "foo/bar")
     html = b"".join(response).decode("utf-8")
     assert html.startswith("<!DOCTYPE html>")
     assert_in("http://www.example.com/foo/bar", html)
示例#5
0
 def umlauts_in_url(self) -> None:
     self.environment["SERVER_NAME"] = "www.example.com"
     request = Request(self.environment)
     see_other(request, self.start_response, "foo/bär")
     self.start_response.assert_header_equals(
         "Location", "http://www.example.com/foo/b%C3%A4r")
示例#6
0
 def absolute_url(self) -> None:
     request = Request(self.environment)
     see_other(request, self.start_response, "http://example.com/foo")
     self.start_response.assert_header_equals("Location",
                                              "http://example.com/foo")
示例#7
0
文件: handler.py 项目: srittau/rouver
 def see_other(self, url_part: str) -> Iterable[bytes]:
     return see_other(self.request, self.start_response, url_part)