当前位置: 首页>>代码示例>>Python>>正文


Python TChannel.json方法代码示例

本文整理汇总了Python中tchannel.tornado.TChannel.json方法的典型用法代码示例。如果您正苦于以下问题:Python TChannel.json方法的具体用法?Python TChannel.json怎么用?Python TChannel.json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tchannel.tornado.TChannel的用法示例。


在下文中一共展示了TChannel.json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_vcr_with_tracing

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import json [as 别名]
def test_vcr_with_tracing(
    tmpdir, mock_server, tracer, tracing_before, tracing_after
):
    from tchannel import TChannel

    mock_server.expect_call('hello', 'json').and_write('world').once()

    path = tmpdir.join('data.yaml')

    if tracing_before:
        ch = TChannel('client', trace=True, tracer=tracer)
    else:
        ch = TChannel('client')

    with vcr.use_cassette(str(path)) as cass:
        response = yield ch.json(
            hostport=mock_server.hostport,
            service='hello_service',
            endpoint='hello',
            body='world',
        )
        assert 'world' == response.body

    assert cass.play_count == 0
    assert path.check(file=True)

    if tracing_after:
        ch = TChannel('client', trace=True, tracer=tracer)
    else:
        ch = TChannel('client')

    with vcr.use_cassette(str(path), record_mode=vcr.RecordMode.NONE) as cass:
        response = yield ch.json(
            hostport=mock_server.hostport,
            service='hello_service',
            endpoint='hello',
            body='world',
        )
        assert 'world' == response.body

    assert cass.play_count == 1
开发者ID:uber,项目名称:tchannel-python,代码行数:43,代码来源:test_vcr.py

示例2: test_old_recording_without_tracing

# 需要导入模块: from tchannel.tornado import TChannel [as 别名]
# 或者: from tchannel.tornado.TChannel import json [as 别名]
def test_old_recording_without_tracing(mock_server, tracer):
    from tchannel import TChannel

    # an existing recording that does not contain tracing information
    path = os.path.join(
        os.path.dirname(__file__), 'data', 'old_without_tracing.yaml'
    )
    ch = TChannel('client', trace=True, tracer=tracer)

    mock_server.expect_call('hello', 'json').and_write('world').once()
    with vcr.use_cassette(path, record_mode=vcr.RecordMode.NONE):
        response = yield ch.json(
            hostport=mock_server.hostport,
            service='hello_service',
            endpoint='hello',
            body='world',
        )
        assert 'world' == response.body
开发者ID:uber,项目名称:tchannel-python,代码行数:20,代码来源:test_vcr.py


注:本文中的tchannel.tornado.TChannel.json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。