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

Class _FakeWorkResource

tests/lib/environments/test_worker.py:36–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class _FakeWorkResource:
37 def __init__(self, *, heartbeat_state: str = "stopping") -> None:
38 self._heartbeat_state = heartbeat_state
39 self.heartbeat_calls: list[dict[str, Any]] = []
40 self.stop_calls: list[dict[str, Any]] = []
41
42 async def heartbeat(
43 self,
44 work_id: str,
45 *,
46 environment_id: str,
47 expected_last_heartbeat: str, # noqa: ARG002
48 extra_headers: Any = None,
49 ) -> Any:
50 self.heartbeat_calls.append(
51 {"work_id": work_id, "environment_id": environment_id, "extra_headers": extra_headers}
52 )
53 return SimpleNamespace(last_heartbeat="hb-1", ttl_seconds=60, state=self._heartbeat_state, lease_extended=True)
54
55 async def stop(
56 self,
57 work_id: str,
58 *,
59 environment_id: str,
60 force: bool = False,
61 extra_headers: Any = None,
62 betas: Any = None,
63 ) -> None:
64 self.stop_calls.append(
65 {
66 "work_id": work_id,
67 "environment_id": environment_id,
68 "force": force,
69 "extra_headers": extra_headers,
70 "betas": betas,
71 }
72 )
73
74
75class _FakeSessions:

Calls

no outgoing calls