def test_structure_inject_headers(): expected_proxy = (ProxyBuilder().with_inject_headers({ "X-Clacks-Overhead": "GNU Terry Pratchett" }).build()) proxy_structure = expected_proxy.as_structure() proxy = BaseResponse.from_structure(proxy_structure) assert proxy.inject_headers == expected_proxy.inject_headers
def test_response_structure_roundtrip(): # Given expected = ResponseBuilder(mode=None, copy=None, lookup=None).build() structure = expected.as_structure() # When actual = BaseResponse.from_structure(structure) # Then assert_that(actual, instance_of(Response)) assert_that(actual, has_identical_properties_to(expected))
def test_tcp_response_structure_roundtrip(): # Given expected = TcpResponseBuilder().build() structure = expected.as_structure() # When actual = BaseResponse.from_structure(structure) # Then assert_that(actual, instance_of(TcpResponse)) assert_that(actual, has_identical_properties_to(expected))
def test_response_with_copy_and_lookup_structure_roundtrip(): # Given expected = ResponseBuilder(mode=Response.Mode.TEXT, copy=CopyBuilder().build(), lookup=LookupBuilder().build()).build() structure = expected.as_structure() # When actual = BaseResponse.from_structure(structure) # Then assert_that(actual, instance_of(Response)) assert_that(actual, has_identical_properties_to(expected))
def test_structure_decorate(): expected_proxy = ProxyBuilder().with_decorate("(req, res) => {}").build() proxy_structure = expected_proxy.as_structure() proxy = BaseResponse.from_structure(proxy_structure) assert proxy.decorate == expected_proxy.decorate
def test_structure_mode(): expected_proxy = ProxyBuilder().with_mode(Proxy.Mode.TRANSPARENT).build() proxy_structure = expected_proxy.as_structure() proxy = BaseResponse.from_structure(proxy_structure) assert proxy.mode == expected_proxy.mode
def test_structure_wait(): expected_proxy = ProxyBuilder().with_wait(200).build() proxy_structure = expected_proxy.as_structure() proxy = BaseResponse.from_structure(proxy_structure) assert proxy.wait == expected_proxy.wait
def test_structure_to(): expected_proxy = ProxyBuilder().build() proxy_structure = expected_proxy.as_structure() proxy = BaseResponse.from_structure(proxy_structure) assert proxy.to == expected_proxy.to
def test_structure_wait(): expected_response = Response(wait=300) response_structure = expected_response.as_structure() response = BaseResponse.from_structure(response_structure) assert response.wait == expected_response.wait
def test_structure_repeat(): expected_response = Response(repeat=1) response_structure = expected_response.as_structure() response = BaseResponse.from_structure(response_structure) assert response.repeat == expected_response.repeat
def test_structure_no_status(): expected_response = Response() response_structure = expected_response.as_structure() del response_structure["is"]["statusCode"] response = BaseResponse.from_structure(response_structure) assert response.status_code == expected_response.status_code
def test_structure_status(): expected_response = Response(status_code=204) response_structure = expected_response.as_structure() response = BaseResponse.from_structure(response_structure) assert response.status_code == expected_response.status_code
def test_structure_body(): expected_response = Response(body="darwin") response_structure = expected_response.as_structure() response = BaseResponse.from_structure(response_structure) assert response.body == expected_response.body
def test_structure_headers(): expected_response = Response( headers={"X-Clacks-Overhead": "GNU Terry Pratchett"}) response_structure = expected_response.as_structure() response = BaseResponse.from_structure(response_structure) assert response.headers == expected_response.headers