35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from pathlib import Path
|
|
|
|
import httpx
|
|
import pytest
|
|
|
|
from agentci.adapters.opencode import OpenCodeClient, OpenCodeError
|
|
|
|
|
|
def client(tmp_path: Path, status: int) -> OpenCodeClient:
|
|
return OpenCodeClient(
|
|
base_url="http://opencode:4096",
|
|
username="opencode",
|
|
password="secret",
|
|
schemas_dir=tmp_path,
|
|
health_directory=tmp_path,
|
|
required_models=(),
|
|
timeout_seconds=60,
|
|
transport=httpx.MockTransport(lambda _request: httpx.Response(status)),
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize("status", [200, 204, 404, 409])
|
|
async def test_absent_or_inactive_session_is_success(tmp_path: Path, status: int) -> None:
|
|
value = client(tmp_path, status)
|
|
await value.abort("session", tmp_path)
|
|
await value.close()
|
|
|
|
|
|
@pytest.mark.parametrize("status", [400, 429, 500])
|
|
async def test_abort_failure_is_visible_for_retry(tmp_path: Path, status: int) -> None:
|
|
value = client(tmp_path, status)
|
|
with pytest.raises(OpenCodeError):
|
|
await value.abort("session", tmp_path)
|
|
await value.close()
|