Fix memleak and simplify dynamic client api

This commit is contained in:
Jason Paryani
2013-10-17 19:15:40 -07:00
parent a5d0abb49f
commit 7f7b28f328
5 changed files with 91 additions and 117 deletions

View File

@@ -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)