Пример #1
0
def test_after_receive_response(statsd_hook, request):
    response = Response(code=StatusCode.ok)
    statsd_hook.after_receive_response(request, response)
    statsd_hook._statsd.count.assert_called_with(
        "tchannel.outbound.calls.success.no-service.test.endpoint1", 1)

    response = Response(code=StatusCode.error)
    statsd_hook.after_receive_response(request, response)
    statsd_hook._statsd.count.assert_called_with(
        "tchannel.outbound.calls.app-errors.no-service.test.endpoint1", 1)
Пример #2
0
def test_build_raw_response_message():
    message_factory = MessageFactory()
    resp = Response(
        flags=FlagsType.none,
        code=StatusCode.ok,
        headers={},
        id=1111,
    )
    resp.state = StreamState.init
    message = message_factory.build_raw_response_message(resp, None, True)
    assert message.code == resp.code
    assert message.flags == resp.flags
    assert message.id == resp.id
    assert message.headers == resp.headers
Пример #3
0
def test_response_exception():
    resp = Response()
    yield resp.write_body("aaa")

    with pytest.raises(StreamingError):
        yield resp.write_header("aaa")

    resp.flush()
    with pytest.raises(TChannelError):
        yield resp.write_body("aaaa")