From 21e4607abd676cb0d33255338b01121f91b008c8 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Fri, 1 Nov 2024 12:14:54 +0100 Subject: [PATCH] restore test coverage --- tests/client/models/test_apiserver.py | 35 +++++++++++++++++++++++++++ tests/client/models/test_model.py | 6 +++++ 2 files changed, 41 insertions(+) diff --git a/tests/client/models/test_apiserver.py b/tests/client/models/test_apiserver.py index 3dbaa0a9..2efffe00 100644 --- a/tests/client/models/test_apiserver.py +++ b/tests/client/models/test_apiserver.py @@ -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={}) diff --git a/tests/client/models/test_model.py b/tests/client/models/test_model.py index 2d1dd53a..7d07dcee 100644 --- a/tests/client/models/test_model.py +++ b/tests/client/models/test_model.py @@ -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