本文整理汇总了Python中tchannel.thrift_request_builder函数的典型用法代码示例。如果您正苦于以下问题:Python thrift_request_builder函数的具体用法?Python thrift_request_builder怎么用?Python thrift_request_builder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了thrift_request_builder函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_second_service_second_test_string
def test_second_service_second_test_string():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testString(request):
return request.body.thing
@server.thrift.register(SecondService)
@gen.coroutine
def secondtestString(request):
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
resp = yield tchannel.thrift(
service.testString(request.body.thing),
)
raise gen.Return(resp)
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport
)
second_service = thrift_request_builder(
service='server',
thrift_module=SecondService,
hostport=server.hostport,
)
resp = yield tchannel.thrift(service.testString('thing'))
assert isinstance(resp, Response)
assert resp.headers == {}
assert resp.body == 'thing'
resp = yield tchannel.thrift(
second_service.secondtestString('second_string')
)
assert isinstance(resp, Response)
assert resp.headers == {}
assert resp.body == 'second_string'
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:56,代码来源:test_thrift.py
示例2: test_string_map
def test_string_map():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testStringMap(request):
return request.body.thing
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
x = {
'hello': 'there',
'my': 'name',
'is': 'shirly',
}
resp = yield tchannel.thrift(
service.testStringMap(thing=x)
)
assert resp.headers == {}
assert resp.body == x
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:33,代码来源:test_thrift.py
示例3: test_map
def test_map():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testMap(request):
return request.body.thing
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
x = {
0: 1,
1: 2,
2: 3,
3: 4,
-1: -2,
}
resp = yield tchannel.thrift(
service.testMap(thing=x)
)
assert resp.headers == {}
assert resp.body == x
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:35,代码来源:test_thrift.py
示例4: test_binary
def test_binary():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testBinary(request):
return request.body.thing
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
resp = yield tchannel.thrift(
service.testBinary(
# this is ThriftTest.Xtruct(string_thing='hi')
'\x0c\x00\x00\x0b\x00\x01\x00\x00\x00\x0bhi\x00\x00'
)
)
assert resp.headers == {}
assert (
resp.body ==
'\x0c\x00\x00\x0b\x00\x01\x00\x00\x00\x0bhi\x00\x00'
)
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:34,代码来源:test_thrift.py
示例5: test_struct
def test_struct():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testStruct(request):
assert request.body.thing.string_thing == 'req string'
return ThriftTest.Xtruct(
string_thing="resp string"
)
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='service',
thrift_module=ThriftTest,
hostport=server.hostport
)
resp = yield tchannel.thrift(
service.testStruct(ThriftTest.Xtruct("req string"))
)
# verify response
assert isinstance(resp, Response)
assert resp.headers == {}
assert resp.body == ThriftTest.Xtruct("resp string")
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:35,代码来源:test_thrift.py
示例6: test_i32
def test_i32():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testI32(request):
return request.body.thing
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
# case #1
resp = yield tchannel.thrift(
service.testI32(-1)
)
assert resp.headers == {}
assert resp.body == -1
# case #2
resp = yield tchannel.thrift(
service.testI32(1)
)
assert resp.headers == {}
assert resp.body == 1
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:35,代码来源:test_thrift.py
示例7: test_double
def test_double():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testDouble(request):
return request.body.thing
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
resp = yield tchannel.thrift(
service.testDouble(-5.235098235)
)
assert resp.headers == {}
assert resp.body == -5.235098235
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:28,代码来源:test_thrift.py
示例8: test_value_expected_but_none_returned_should_error
def test_value_expected_but_none_returned_should_error():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testString(request):
pass
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
with pytest.raises(ValueExpectedError):
yield tchannel.thrift(
service.testString('no return!?')
)
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:26,代码来源:test_thrift.py
示例9: test_call_unexpected_error_should_result_in_unexpected_error
def test_call_unexpected_error_should_result_in_unexpected_error():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testMultiException(request):
raise Exception('well, this is unfortunate')
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
with pytest.raises(UnexpectedError):
yield tchannel.thrift(
service.testMultiException(arg0='Xception', arg1='thingy')
)
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:26,代码来源:test_thrift.py
示例10: test_call_response_should_contain_transport_headers
def test_call_response_should_contain_transport_headers():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testString(request):
return request.body.thing
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
resp = yield tchannel.thrift(service.testString('hi'))
# verify response
assert isinstance(resp, Response)
assert resp.headers == {}
assert resp.body == 'hi'
# verify response transport headers
assert isinstance(resp.transport, TransportHeaders)
assert resp.transport.scheme == schemes.THRIFT
assert resp.transport.failure_domain is None
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:33,代码来源:test_thrift.py
示例11: test_void
def test_void():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testVoid(request):
pass
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
resp = yield tchannel.thrift(service.testVoid())
assert resp.headers == {}
assert resp.body is None
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:26,代码来源:test_thrift.py
示例12: test_enum
def test_enum():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testEnum(request):
return request.body.thing
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
x = ThriftTest.Numberz.FIVE
resp = yield tchannel.thrift(
service.testEnum(thing=x)
)
assert resp.headers == {}
assert resp.body == x
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:29,代码来源:test_thrift.py
示例13: test_call
def test_call(mock_server, thrift_service):
expected = thrift_service.Item(
key='foo', value=thrift_service.Value(integerValue=42)
)
mock_server.expect_call(
thrift_service,
'thrift',
method='getItem',
).and_result(expected)
thrift_service = thrift_request_builder(
service='thrift-service',
thrift_module=thrift_service,
hostport=mock_server.hostport,
)
tchannel = TChannel('test-client')
future = tchannel.thrift(
thrift_service.getItem('foo')
)
result = future.result()
assert expected == result.body
开发者ID:dnathe4th,项目名称:tchannel-python,代码行数:26,代码来源:test_thrift.py
示例14: test_type_def
def test_type_def():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testTypedef(request):
return request.body.thing
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
x = 0xffffffffffffff # 7 bytes of 0xff
resp = yield tchannel.thrift(
service.testTypedef(thing=x)
)
assert resp.headers == {}
assert resp.body == x
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:29,代码来源:test_thrift.py
示例15: test_oneway
def test_oneway():
# Given this test server:
server = TChannel(name='server')
# TODO - server should raise same exception as client
with pytest.raises(AssertionError):
@server.thrift.register(ThriftTest)
def testOneway(request):
pass
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
with pytest.raises(OneWayNotSupportedError):
yield tchannel.thrift(service.testOneway(1))
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:26,代码来源:test_thrift.py
示例16: test_void_with_headers
def test_void_with_headers():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testVoid(request):
assert request.headers == {'req': 'header'}
return Response(headers={'resp': 'header'})
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
resp = yield tchannel.thrift(
service.testVoid(),
headers={'req': 'header'},
)
assert resp.headers == {
'resp': 'header'
}
assert resp.body is None
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:32,代码来源:test_thrift.py
示例17: test_insanity
def test_insanity():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testInsanity(request):
result = {
1: {
2: request.body.argument,
3: request.body.argument,
},
2: {
6: ThriftTest.Insanity(),
},
}
return result
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport,
)
x = ThriftTest.Insanity(
userMap={
ThriftTest.Numberz.EIGHT: 0xffffffffffffff,
},
xtructs=[
ThriftTest.Xtruct(
string_thing='Hello2',
byte_thing=74,
i32_thing=0xff00ff,
i64_thing=-34359738368,
),
],
)
resp = yield tchannel.thrift(
service.testInsanity(x)
)
assert resp.headers == {}
assert resp.body == {
1: {
2: x,
3: x,
},
2: {
6: ThriftTest.Insanity(),
},
}
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:59,代码来源:test_thrift.py
示例18: test_second_service_blah_blah
def test_second_service_blah_blah():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testString(request):
return request.body.thing
@server.thrift.register(SecondService)
def blahBlah(request):
pass
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='server',
thrift_module=ThriftTest,
hostport=server.hostport
)
second_service = thrift_request_builder(
service='server',
thrift_module=SecondService,
hostport=server.hostport,
)
resp = yield tchannel.thrift(service.testString('thing'))
assert isinstance(resp, Response)
assert resp.headers == {}
assert resp.body == 'thing'
resp = yield tchannel.thrift(second_service.blahBlah())
assert isinstance(resp, Response)
assert resp.headers == {}
assert resp.body is None
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:43,代码来源:test_thrift.py
示例19: test_multi_exception
def test_multi_exception():
# Given this test server:
server = TChannel(name='server')
@server.thrift.register(ThriftTest)
def testMultiException(request):
if request.body.arg0 == 'Xception':
raise ThriftTest.Xception(
errorCode=1001,
message='This is an Xception',
)
elif request.body.arg0 == 'Xception2':
raise ThriftTest.Xception2(
errorCode=2002
)
return ThriftTest.Xtruct(string_thing=request.body.arg1)
server.listen()
# Make a call:
tchannel = TChannel(name='client')
service = thrift_request_builder(
service='service',
thrift_module=ThriftTest,
hostport=server.hostport
)
# case #1
with pytest.raises(ThriftTest.Xception) as e:
yield tchannel.thrift(
service.testMultiException(arg0='Xception', arg1='thingy')
)
assert e.value.errorCode == 1001
assert e.value.message == 'This is an Xception'
# case #2
with pytest.raises(ThriftTest.Xception2) as e:
yield tchannel.thrift(
service.testMultiException(arg0='Xception2', arg1='thingy')
)
assert e.value.errorCode == 2002
# case #3
resp = yield tchannel.thrift(
service.testMultiException(arg0='something else', arg1='thingy')
)
assert isinstance(resp, Response)
assert resp.headers == {}
assert resp.body == ThriftTest.Xtruct('thingy')
开发者ID:MadanThangavelu,项目名称:tchannel-python,代码行数:55,代码来源:test_thrift.py
示例20: secondtestString
def secondtestString(request):
service = thrift_request_builder(
service='server',
thrift_module=_ThriftTest,
hostport=server.hostport,
)
resp = yield tchannel.thrift(
service.testString(request.body.thing),
)
raise gen.Return(resp)
开发者ID:encrylife,项目名称:tchannel-python,代码行数:11,代码来源:test_thrift.py
注:本文中的tchannel.thrift_request_builder函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论