Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | """Exercise item schemas through the real optional Google ADK provider.""" |
| 2 | |
| 3 | import socket |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | from composio.client.types import Tool |
| 8 | |
| 9 | google_adk = pytest.importorskip("composio_google_adk") |
| 10 | |
| 11 | |
| 12 | @pytest.mark.unit |
| 13 | @pytest.mark.schema |
| 14 | @pytest.mark.parametrize("combiner", ["anyOf", "oneOf"]) |
| 15 | # Exceed the converter budget without hitting unrelated schema-copy limits. |
| 16 | @pytest.mark.parametrize("depth", [0, 96], ids=["nullable", "depth-limit"]) |
| 17 | def test_array_items_reach_the_adk_declaration(combiner, depth, monkeypatch): |
| 18 | def reject_network(*args, **kwargs): |
| 19 | pytest.fail("Tool declaration generation must not use the network") |
| 20 | |
| 21 | monkeypatch.setattr(socket.socket, "connect", reject_network) |
| 22 | monkeypatch.setattr(socket, "getaddrinfo", reject_network) |
| 23 | items = {combiner: [{"type": "string"}, {"type": "null"}]} |
| 24 | for _ in range(depth): |
| 25 | items = {combiner: [items]} |
| 26 | tool = Tool.model_construct( |
| 27 | slug="offline_schema_probe", |
| 28 | description="Offline schema probe", |
| 29 | input_parameters={ |
| 30 | "type": "object", |
| 31 | "properties": { |
| 32 | "values": { |
| 33 | "type": "array", |
| 34 | "items": items, |
| 35 | } |
| 36 | }, |
| 37 | "required": ["values"], |
| 38 | }, |
| 39 | ) |
| 40 | |
| 41 | def execute_tool(**kwargs): |
| 42 | pytest.fail("Generating a tool declaration must not execute the tool") |
| 43 | |
| 44 | wrapped = google_adk.GoogleAdkProvider().wrap_tool(tool, execute_tool=execute_tool) |
| 45 | declaration = wrapped._get_declaration() |
| 46 | expected_items = {} if depth else {"anyOf": [{"type": "string"}, {"type": "null"}]} |
| 47 | assert ( |
| 48 | declaration.parameters_json_schema["properties"]["values"]["items"] |
| 49 | == expected_items |
| 50 | ) |