MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / FakeWork

Class FakeWork

tests/lib/environments/test_poller_method.py:44–65  ·  view source on GitHub ↗

Sync resource fake. ``poll_script`` is consumed in order; values are either ``BetaSelfHostedWork``-shaped stubs, ``None`` (no work available), ``Exception`` instances (raised from poll), or callables producing one of those (so a script step can also move a fake clock).

Source from the content-addressed store, hash-verified

42
43
44class FakeWork:
45 """Sync resource fake. ``poll_script`` is consumed in order; values are
46 either ``BetaSelfHostedWork``-shaped stubs, ``None`` (no work available),
47 ``Exception`` instances (raised from poll), or callables producing one of
48 those (so a script step can also move a fake clock).
49 """
50
51 def __init__(self, poll_script: list[Any]) -> None:
52 self._poll_script = list(poll_script)
53 self.poll_calls: list[dict[str, Any]] = []
54 self.ack_calls: list[tuple[str, dict[str, Any]]] = []
55 self.stop_calls: list[tuple[str, dict[str, Any]]] = []
56
57 def poll(self, environment_id: str, **kwargs: Any) -> Any:
58 self.poll_calls.append({"environment_id": environment_id, **kwargs})
59 return _next_poll_result(self._poll_script)
60
61 def ack(self, work_id: str, **kwargs: Any) -> None:
62 self.ack_calls.append((work_id, kwargs))
63
64 def stop(self, work_id: str, **kwargs: Any) -> None:
65 self.stop_calls.append((work_id, kwargs))
66
67
68class FakeAsyncWork:

Calls

no outgoing calls