restatedev / restatedev/sdk-python

[test harness] consider an even simpler harness

Open
#153 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
81
Forks
22
Avg merge
2d 2h
Merged PRs (30d)
2

Description

@asynccontextmanager
async def simple_harness(service: Service | VirtualObject | Workflow) -> typing.AsyncIterator[restate.RestateClient]:
    async with restate.create_test_harness(
        restate.app([service]), restate_image="ghcr.io/restatedev/restate:latest"
    ) as restate_test_harness:
        yield restate_test_harness.client

with that we can write tests that cover a single handler/serivce like that:

async def test_sanity():
    greeter = Service("greeter")

    @greeter.handler()
    async def greet(ctx: Context, name: str) -> str:
        return "hi"

    async with simple_harness(greeter) as client:
             assert "hi" == await client.service_call(greet, arg="bob")

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the create_test_harness entry point shown in the issue and inspect how a Service, VirtualObject, or Workflow is currently passed into the test harness. Implement and verify the simple_harness usage demonstrated by the sanity test, including obtaining a client and calling the greet handler.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.