Ejemplo n.º 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
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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