Skip to content

Commit

Permalink
restore test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Nov 1, 2024
1 parent 8e3da6d commit 21e4607
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/client/models/test_apiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,41 @@ async def test_session_collection_create(client: Any) -> None:
)


@pytest.mark.asyncio
async def test_session_collection_list(client: Any) -> None:
# Mock response containing list of sessions
client.request.return_value = mock.MagicMock(
json=lambda: [
SessionDefinition(session_id="session1"),
SessionDefinition(session_id="session2"),
]
)

# Create session collection instance
coll = SessionCollection(
client=client,
items={},
deployment_id="a_deployment",
)

# Call list method
sessions = await coll.list()

# Verify request was made correctly
client.request.assert_awaited_with(
"GET",
"http://localhost:4501/deployments/a_deployment/sessions",
verify=True,
timeout=120.0,
)

# Verify returned sessions
assert len(sessions) == 2
assert all(isinstance(session, Session) for session in sessions)
assert sessions[0].id == "session1"
assert sessions[1].id == "session2"


@pytest.mark.asyncio
async def test_task_results(client: Any) -> None:
res = TaskResult(task_id="a_result", history=[], result="some_text", data={})
Expand Down
6 changes: 6 additions & 0 deletions tests/client/models/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def test_make_sync_instance(client: Client) -> None:
assert some_sync.method() + 1 == 1


def test__prepare(client: Client) -> None:
some_sync = make_sync(SomeAsyncModel)(client=client, id="foo")
coll = some_sync._prepare(Collection)
assert coll._instance_is_sync


def test_collection_get() -> None:
class MyCollection(Collection):
pass
Expand Down

0 comments on commit 21e4607

Please sign in to comment.