本文整理汇总了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
示例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