Remove all public references to EventLoop to match changes to async API

This commit is contained in:
Jason Paryani
2013-12-02 17:38:32 -08:00
parent d1de275187
commit 888b906781
11 changed files with 168 additions and 195 deletions

View File

@@ -30,15 +30,13 @@ class PipelineServer:
return context.params.inCap.foo(i=context.params.n).then(_then)
def test_client(capability):
loop = capnp.EventLoop()
client = capability.TestInterface._new_client(Server(), loop)
client = capability.TestInterface._new_client(Server())
req = client._request('foo')
req.i = 5
remote = req.send()
response = loop.wait(remote)
response = remote.wait()
assert response.x == '26'
@@ -46,7 +44,7 @@ def test_client(capability):
req.i = 5
remote = req.send()
response = loop.wait(remote)
response = remote.wait()
assert response.x == '26'
@@ -64,43 +62,41 @@ def test_client(capability):
req.baz = 1
def test_simple_client(capability):
loop = capnp.EventLoop()
client = capability.TestInterface._new_client(Server(), loop)
client = capability.TestInterface._new_client(Server())
remote = client._send('foo', i=5)
response = loop.wait(remote)
response = remote.wait()
assert response.x == '26'
remote = client.foo(i=5)
response = loop.wait(remote)
response = remote.wait()
assert response.x == '26'
remote = client.foo(i=5, j=True)
response = loop.wait(remote)
response = remote.wait()
assert response.x == '27'
remote = client.foo(5)
response = loop.wait(remote)
response = remote.wait()
assert response.x == '26'
remote = client.foo(5, True)
response = loop.wait(remote)
response = remote.wait()
assert response.x == '27'
remote = client.foo(5, j=True)
response = loop.wait(remote)
response = remote.wait()
assert response.x == '27'
remote = client.buz(capability.TestSturdyRefHostId.new_message(host='localhost'))
response = loop.wait(remote)
response = remote.wait()
assert response.x == 'localhost_test'
@@ -120,20 +116,18 @@ def test_simple_client(capability):
remote = client.foo(baz=5)
def test_pipeline(capability):
loop = capnp.EventLoop()
client = capability.TestPipeline._new_client(PipelineServer(), loop)
foo_client = capability.TestInterface._new_client(Server(), loop)
client = capability.TestPipeline._new_client(PipelineServer())
foo_client = capability.TestInterface._new_client(Server())
remote = client.getCap(n=5, inCap=foo_client)
outCap = remote.outBox.cap
pipelinePromise = outCap.foo(i=10)
response = loop.wait(pipelinePromise)
response = pipelinePromise.wait()
assert response.x == '150'
response = loop.wait(remote)
response = remote.wait()
assert response.s == '26_foo'
class BadServer:
@@ -145,13 +139,11 @@ class BadServer:
context.results.x2 = 5 # raises exception
def test_exception_client(capability):
loop = capnp.EventLoop()
client = capability.TestInterface._new_client(BadServer(), loop)
client = capability.TestInterface._new_client(BadServer())
remote = client._send('foo', i=5)
with pytest.raises(capnp.KjException):
loop.wait(remote)
remote.wait()
class BadPipelineServer:
def getCap_context(self, context):
@@ -164,23 +156,19 @@ class BadPipelineServer:
return context.params.inCap.foo(i=context.params.n).then(_then, _error)
def test_exception_chain(capability):
loop = capnp.EventLoop()
client = capability.TestPipeline._new_client(BadPipelineServer(), loop)
foo_client = capability.TestInterface._new_client(BadServer(), loop)
client = capability.TestPipeline._new_client(BadPipelineServer())
foo_client = capability.TestInterface._new_client(BadServer())
remote = client.getCap(n=5, inCap=foo_client)
try:
loop.wait(remote)
remote.wait()
except Exception as e:
assert 'test was a success' in str(e)
def test_pipeline_exception(capability):
loop = capnp.EventLoop()
client = capability.TestPipeline._new_client(BadPipelineServer(), loop)
foo_client = capability.TestInterface._new_client(BadServer(), loop)
client = capability.TestPipeline._new_client(BadPipelineServer())
foo_client = capability.TestInterface._new_client(BadServer())
remote = client.getCap(n=5, inCap=foo_client)
@@ -191,12 +179,10 @@ def test_pipeline_exception(capability):
loop.wait(pipelinePromise)
with pytest.raises(Exception):
loop.wait(remote)
remote.wait()
def test_casting(capability):
loop = capnp.EventLoop()
client = capability.TestExtends._new_client(Server(), loop)
client = capability.TestExtends._new_client(Server())
client2 = client.upcast(capability.TestInterface)
client3 = client2.cast_as(capability.TestInterface)