@asynccontextmanagerasyncdefsimple_harness(service: Service|VirtualObject|Workflow) ->typing.AsyncIterator[restate.RestateClient]:
asyncwithrestate.create_test_harness(
restate.app([service]), restate_image="ghcr.io/restatedev/restate:latest"
) asrestate_test_harness:
yieldrestate_test_harness.client
with that we can write tests that cover a single handler/serivce like that:
asyncdeftest_sanity():
greeter=Service("greeter")
@greeter.handler()asyncdefgreet(ctx: Context, name: str) ->str:
return"hi"asyncwithsimple_harness(greeter) asclient:
assert"hi"==awaitclient.service_call(greet, arg="bob")
with that we can write tests that cover a single handler/serivce like that: