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

Class FakeWork

tests/lib/environments/test_poller_method.py:56–79  ·  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

54
55
56class FakeWork:
57 """Sync resource fake. `poll_script` is consumed in order; values are
58 either `BetaSelfHostedWork`-shaped stubs, `None` (no work available),
59 `Exception` instances (raised from poll), or callables producing one of
60 those (so a script step can also move a fake clock).
61 """
62
63 _client = SimpleNamespace(_tracer=None)
64
65 def __init__(self, poll_script: list[Any]) -> None:
66 self._poll_script = list(poll_script)
67 self.poll_calls: list[dict[str, Any]] = []
68 self.ack_calls: list[tuple[str, dict[str, Any]]] = []
69 self.stop_calls: list[tuple[str, dict[str, Any]]] = []
70
71 def poll(self, environment_id: str, **kwargs: Any) -> Any:
72 self.poll_calls.append({"environment_id": environment_id, **kwargs})
73 return _next_poll_result(self._poll_script)
74
75 def ack(self, work_id: str, **kwargs: Any) -> None:
76 self.ack_calls.append((work_id, kwargs))
77
78 def stop(self, work_id: str, **kwargs: Any) -> None:
79 self.stop_calls.append((work_id, kwargs))
80
81
82class FakeAsyncWork:

Calls

no outgoing calls