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.
()
| 71 | |
| 72 | |
| 73 | def 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 | |
| 92 | def _repo_config() -> str | None: |
no test coverage detected