@devries-cameron20 / composio-1 / commits / d94aa32a4
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

test: add unit tests for the schema_converter boolean-schema filter (#3876)

## Description `composio.utils.schema_converter._filter_boolean_schemas` pre-processes JSON Schemas before handing them to `json-schema-to-pydantic`, which doesn't support boolean schemas (draft-06+ allows `true`/`false` as schemas). It replaces `true` with `{}`, drops `false`, and recurses through combiner arrays (`anyOf`/`allOf`/`oneOf`), `properties`, `items` and `$defs`. It had no test coverage. This adds `python/tests/test_schema_converter.py` covering: - `True` -> `{}` and `False` -> `None` - non-schema values passing through unchanged - lists dropping `False` entries, and an all-`False` list becoming `None` - combiner arrays dropping `False` entries, and the whole combiner being removed when every entry is `False` - a `False` property being dropped while siblings are kept - plain keys being preserved No source changes. ## Verification `pytest python/tests/test_schema_converter.py` - 9 passed. `ruff check` / `ruff format` clean. Co-authored-by: jkomyno <alberto@composio.dev>

eeshsaxena committed Jul 28, 2026 at 13:18 UTC d94aa32a41548885781c0a415aaa2d1d171379fe
1 file changed +46
python/tests/test_schema_converter.py new
+46
@@ -0,0 +1,46 @@
1 +"""Tests for the schema_converter boolean-schema pre-filter."""
2 +
3 +from composio.utils.schema_converter import _filter_boolean_schemas
4 +
5 +
6 +def test_true_becomes_empty_schema():
7 + assert _filter_boolean_schemas(True) == {}
8 +
9 +
10 +def test_false_becomes_none():
11 + assert _filter_boolean_schemas(False) is None
12 +
13 +
14 +def test_non_schema_value_passes_through():
15 + assert _filter_boolean_schemas("passthrough") == "passthrough"
16 +
17 +
18 +def test_list_drops_false_and_keeps_rest():
19 + assert _filter_boolean_schemas([True, False, {"type": "string"}]) == [
20 + {},
21 + {"type": "string"},
22 + ]
23 +
24 +
25 +def test_list_of_all_false_becomes_none():
26 + assert _filter_boolean_schemas([False, False]) is None
27 +
28 +
29 +def test_combiner_drops_false_entries():
30 + schema = {"anyOf": [{"type": "string"}, False]}
31 + assert _filter_boolean_schemas(schema) == {"anyOf": [{"type": "string"}]}
32 +
33 +
34 +def test_combiner_removed_when_all_entries_false():
35 + schema = {"type": "object", "anyOf": [False, False]}
36 + assert _filter_boolean_schemas(schema) == {"type": "object"}
37 +
38 +
39 +def test_false_property_is_dropped():
40 + schema = {"properties": {"a": False, "b": {"type": "string"}}}
41 + assert _filter_boolean_schemas(schema) == {"properties": {"b": {"type": "string"}}}
42 +
43 +
44 +def test_plain_keys_are_preserved():
45 + schema = {"type": "string", "title": "X"}
46 + assert _filter_boolean_schemas(schema) == {"type": "string", "title": "X"}