def extra_headers(self) -> None: request = Request(self.environment) created_at( 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) created_at(request, self.start_response, "/foo/bar") self.start_response.assert_status(HTTPStatus.CREATED) 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 = created_at(request, self.start_response, "foo/bar") html = b"".join(response).decode("utf-8") assert html.startswith("<!DOCTYPE html>")
def umlauts_in_url(self) -> None: self.environment["SERVER_NAME"] = "www.example.com" request = Request(self.environment) created_at(request, self.start_response, "foo/bär") self.start_response.assert_header_equals( "Location", "http://www.example.com/foo/b%C3%A4r")
def url_without_leading_slash(self) -> None: self.environment["SERVER_NAME"] = "www.example.com" request = Request(self.environment) created_at(request, self.start_response, "foo/bar") self.start_response.assert_header_equals( "Location", "http://www.example.com/foo/bar")
def absolute_url(self) -> None: request = Request(self.environment) created_at(request, self.start_response, "http://example.com/foo") self.start_response.assert_header_equals("Location", "http://example.com/foo")
def created_at(self, url_part: str) -> Iterable[bytes]: return created_at(self.request, self.start_response, url_part)