示例#1
0
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
示例#2
0
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))
示例#3
0
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))
示例#4
0
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))
示例#5
0
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
示例#6
0
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
示例#7
0
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
示例#8
0
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
示例#9
0
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
示例#10
0
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
示例#11
0
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
示例#12
0
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
示例#13
0
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
示例#14
0
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