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")
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")
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")
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)
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")
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")
def see_other(self, url_part: str) -> Iterable[bytes]: return see_other(self.request, self.start_response, url_part)