IstosTestClient API Reference¶
In-process testing without a live Zenoh network.
In-process test client for handlers, streams and subscribers — no network.
IstosTestClient
¶
Invoke handlers, streams and subscribers in-process. The authorizer gate, validation, DI and durability ledger all still run.
istos = Istos()
@istos.handle("robot/move")
async def move(distance: int):
return {"moved": distance}
client = IstosTestClient(istos)
assert await client.query("robot/move", distance=10) == {"moved": 10}
Pass token= to drive an authorizer; a denied request raises
UnauthorizedError.
Source code in src/istos/testing/testclient.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
channel(prefix, token=None, conversation_id=None, **params)
¶
Open a @channel in-process and return a duplex handle. Use it as an
async context manager; send / receive / async for from the
caller's side while the handler runs::
async with client.channel("agent/chat") as chan:
await chan.send("hi")
assert await chan.receive() == {"role": "system", "text": "ready"}
The authorizer, validation and DI run exactly as on the WebSocket/fabric
transport; a denied token raises UnauthorizedError on enter.
Source code in src/istos/testing/testclient.py
publish(prefix, data, token=None)
async
¶
Deliver data to all matching subscribers in-process.
The authorizer gate runs, the same as a sample arriving on the mesh.
A denial raises UnauthorizedError and nothing is delivered.
Source code in src/istos/testing/testclient.py
query(prefix, token=None, **kwargs)
async
¶
Invoke a handler in-process.
Source code in src/istos/testing/testclient.py
run_publish(prefix, data)
¶
run_query(prefix, **kwargs)
¶
stream(prefix, token=None, **kwargs)
async
¶
Consume a @stream handler in-process, yielding each chunk.
async for chunk in client.stream("llm/generate", prompt="hi"): ...