Fix memleak and simplify dynamic client api
This commit is contained in:
@@ -17,14 +17,56 @@ def test_basic_client(capability):
|
||||
|
||||
client = capability.TestInterface.new_client(Server(), loop)
|
||||
|
||||
req = client.request('foo')
|
||||
req = client._request('foo')
|
||||
req.i = 5
|
||||
|
||||
remote = req.send()
|
||||
remote = client.send('foo', i=10)
|
||||
response = loop.wait_remote(remote)
|
||||
|
||||
# assert response.x == '26'
|
||||
assert response.x == '26'
|
||||
|
||||
req = client.foo_request()
|
||||
req.i = 5
|
||||
|
||||
remote = req.send()
|
||||
response = loop.wait_remote(remote)
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
client.request('foo2')
|
||||
client.foo2_request()
|
||||
|
||||
req = client.foo_request()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
req.i = 'foo'
|
||||
|
||||
req = client.foo_request()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
req.baz = 1
|
||||
|
||||
def test_simple_client(capability):
|
||||
loop = capnp.EventLoop()
|
||||
|
||||
client = capability.TestInterface.new_client(Server(), loop)
|
||||
|
||||
remote = client._send('foo', i=5)
|
||||
response = loop.wait_remote(remote)
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
remote = client.foo(i=5)
|
||||
response = loop.wait_remote(remote)
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
remote = client.foo(i='foo')
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
remote = client.foo2(i=5)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
remote = client.foo(baz=5)
|
||||
|
||||
Reference in New Issue
Block a user