MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_serve_handle_lifecycle

Function test_serve_handle_lifecycle

sdk/python/tests/test_serve.py:73–89  ·  view source on GitHub ↗

Unit (hermetic): serving a dir with no schedules returns a ServeHandle that reports not-stopped, and stop() is idempotent and reflected by is_stopped(). No provider call is made.

()

Source from the content-addressed store, hash-verified

71
72
73def test_serve_handle_lifecycle() -> None:
74 """Unit (hermetic): serving a dir with no schedules returns a ServeHandle
75 that reports not-stopped, and stop() is idempotent and reflected by
76 is_stopped(). No provider call is made."""
77 agent = Agent.create(INLINE_CONFIG)
78 agent_dir = _write_agent_dir(with_schedule=False)
79 workspace = tempfile.mkdtemp(prefix="a3s-code-serve-ws-")
80
81 handle = agent.serve_agent_dir(agent_dir, workspace)
82 assert handle.is_stopped() is False, "handle should not be stopped before stop()"
83
84 handle.stop()
85 assert handle.is_stopped() is True, "stop() must set is_stopped() to True"
86 handle.stop() # idempotent — must not raise
87 assert handle.is_stopped() is True
88
89 print("python sdk serve handle lifecycle ok")
90
91
92def _repo_config() -> str | None:

Callers 1

mainFunction · 0.85

Calls 5

_write_agent_dirFunction · 0.85
createMethod · 0.45
serve_agent_dirMethod · 0.45
is_stoppedMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected