mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 16:35:04 +01:00
Add ez_rpc test
This commit is contained in:
parent
540ed4cdba
commit
60a9421b0e
1 changed files with 29 additions and 0 deletions
|
@ -57,3 +57,32 @@ def test_simple_rpc_restore_func():
|
|||
response = remote.wait()
|
||||
|
||||
assert response.x == '125'
|
||||
|
||||
|
||||
def text_restore_func(objectId):
|
||||
text = objectId.as_text()
|
||||
assert text == 'testInterface'
|
||||
return Server(100)
|
||||
|
||||
|
||||
def test_ez_rpc():
|
||||
read, write = socket.socketpair(socket.AF_UNIX)
|
||||
|
||||
server = capnp.TwoPartyServer(write, text_restore_func)
|
||||
client = capnp.TwoPartyClient(read)
|
||||
|
||||
cap = client.ez_restore('testInterface')
|
||||
cap = cap.cast_as(test_capability_capnp.TestInterface)
|
||||
|
||||
remote = cap.foo(i=5)
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '125'
|
||||
|
||||
cap = client.restore(test_capability_capnp.TestSturdyRefObjectId.new_message())
|
||||
cap = cap.cast_as(test_capability_capnp.TestInterface)
|
||||
|
||||
remote = cap.foo(i=5)
|
||||
|
||||
with pytest.raises(capnp.KjException):
|
||||
response = remote.wait()
|
||||
|
|
Loading…
Add table
Reference in a new issue