diff --git a/agents-api/tests/fixtures.py b/agents-api/tests/fixtures.py index 08602e37e..5c06da9e6 100644 --- a/agents-api/tests/fixtures.py +++ b/agents-api/tests/fixtures.py @@ -159,6 +159,7 @@ async def test_task(dsn=pg_dsn, developer=test_developer, agent=test_agent): description="test task about", input_schema={"type": "object", "additionalProperties": True}, main=[{"evaluate": {"hi": "_"}}], + metadata={"test": True}, ), connection_pool=pool, ) @@ -344,7 +345,7 @@ async def test_session( # yield transition -@fixture(scope="global") +@fixture(scope="test") async def test_tool( dsn=pg_dsn, developer_id=test_developer_id, @@ -356,7 +357,7 @@ async def test_tool( "parameters": {"type": "object", "properties": {}}, } - tool = { + tool_spec = { "function": function, "name": "hello_world1", "type": "function", @@ -365,20 +366,10 @@ async def test_tool( [tool, *_] = await create_tools( developer_id=developer_id, agent_id=agent.id, - data=[CreateToolRequest(**tool)], + data=[CreateToolRequest(**tool_spec)], connection_pool=pool, ) - yield tool - - # Cleanup - try: - await delete_tool( - developer_id=developer_id, - tool_id=tool.id, - connection_pool=pool, - ) - finally: - await pool.close() + return tool @fixture(scope="global") diff --git a/agents-api/tests/test_task_queries.py b/agents-api/tests/test_task_queries.py index 0ff364256..f68365bf0 100644 --- a/agents-api/tests/test_task_queries.py +++ b/agents-api/tests/test_task_queries.py @@ -174,7 +174,9 @@ async def _(dsn=pg_dsn, developer_id=test_developer_id, agent=test_agent): @test("query: list tasks sql - no filters") -async def _(dsn=pg_dsn, developer_id=test_developer_id, agent=test_agent): +async def _( + dsn=pg_dsn, developer_id=test_developer_id, agent=test_agent, task=test_task +): """Test that a list of tasks can be successfully retrieved.""" pool = await create_db_pool(dsn=dsn) @@ -183,10 +185,12 @@ async def _(dsn=pg_dsn, developer_id=test_developer_id, agent=test_agent): agent_id=agent.id, connection_pool=pool, ) - assert result is not None - assert isinstance(result, list) - assert len(result) > 0 - assert all(isinstance(task, Task) for task in result) + assert result is not None, "Result is None" + assert isinstance(result, list), f"Result is not a list, got {type(result)}" + assert len(result) > 0, "Result is empty" + assert all( + isinstance(task, Task) for task in result + ), "Not all listed tasks are of type Task" @test("query: update task sql - exists") diff --git a/agents-api/tests/test_tool_queries.py b/agents-api/tests/test_tool_queries.py index 5056f03ca..01ef570d5 100644 --- a/agents-api/tests/test_tool_queries.py +++ b/agents-api/tests/test_tool_queries.py @@ -81,14 +81,14 @@ async def _( dsn=pg_dsn, developer_id=test_developer_id, tool=test_tool, agent=test_agent ): pool = await create_db_pool(dsn=dsn) - result = get_tool( + result = await get_tool( developer_id=developer_id, agent_id=agent.id, tool_id=tool.id, connection_pool=pool, ) - assert result is not None + assert result is not None, "Result is None" @test("query: list tools") @@ -102,8 +102,11 @@ async def _( connection_pool=pool, ) - assert result is not None - assert all(isinstance(tool, Tool) for tool in result) + assert result is not None, "Result is None" + assert len(result) > 0, "Result is empty" + assert all( + isinstance(tool, Tool) for tool in result + ), "Not all listed tools are of type Tool" @test("query: patch tool")