Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 19:30 UTC
Remove schema parser simple tests
haxzie committed
Sep 29, 2025 at 16:44 UTC
61a75343ebe31f7f34688a50076ba907be92c811
1 file changed
-107
python/tests/test_schema_parser_simple.py
deleted
-107
@@ -1,107 +0,0 @@
1
-#!/usr/bin/env python3
2
-"""
3
-Simple validation tests for schema parser functions.
4
-"""
5
-
6
-import sys
7
-import os
8
-sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
9
-
10
-from pydantic.fields import PydanticUndefined
11
-from composio.utils.shared import (
12
- json_schema_to_model,
13
- json_schema_to_pydantic_field,
14
-)
15
-
16
-
17
-def test_basic_functionality():
18
- """Basic smoke test for schema parser functions."""
19
- print("🧪 Testing basic schema parser functionality...")
20
-
21
- # Test 1: Simple required field
22
- name = "test_field"
23
- json_schema = {
24
- "type": "string",
25
- "description": "A test field",
26
- "title": "Test Field"
27
- }
28
- required = ["test_field"]
29
-
30
- field_name, field_type, field_info = json_schema_to_pydantic_field(
31
- name, json_schema, required
32
- )
33
-
34
- assert field_name == "test_field"
35
- assert field_type is str
36
- assert field_info.default is PydanticUndefined # Required field marker
37
- print("✅ Test 1 passed: Simple required field")
38
-
39
- # Test 2: Optional field with nested required (the bug scenario)
40
- name = "nested_object"
41
- json_schema = {
42
- "type": "object",
43
- "title": "NestedObject",
44
- "properties": {
45
- "inner_field": {
46
- "type": "string",
47
- "title": "Inner Field"
48
- }
49
- },
50
- "required": ["inner_field"] # This should NOT make nested_object required
51
- }
52
- required = [] # nested_object is not in parent's required list
53
-
54
- field_name, field_type, field_info = json_schema_to_pydantic_field(
55
- name, json_schema, required
56
- )
57
-
58
- assert field_name == "nested_object"
59
- assert field_info.default is not PydanticUndefined # Should NOT be required
60
- print("✅ Test 2 passed: Nested object with internal required not propagated")
61
-
62
- # Test 3: Full model creation (workingLocationProperties scenario)
63
- json_schema = {
64
- "title": "CreateEventRequest",
65
- "type": "object",
66
- "properties": {
67
- "start_datetime": {
68
- "type": "string",
69
- "title": "Start Datetime"
70
- },
71
- "workingLocationProperties": {
72
- "type": "object",
73
- "title": "WorkingLocationProperties",
74
- "properties": {
75
- "type": {
76
- "type": "string",
77
- "title": "Type"
78
- }
79
- },
80
- "required": ["type"] # Should NOT make workingLocationProperties required
81
- }
82
- },
83
- "required": ["start_datetime"]
84
- }
85
-
86
- model_class = json_schema_to_model(json_schema)
87
-
88
- # Test that workingLocationProperties is NOT required
89
- instance = model_class(start_datetime="2025-01-01T10:00:00")
90
- assert instance.start_datetime == "2025-01-01T10:00:00"
91
- assert instance.workingLocationProperties is None
92
- print("✅ Test 3 passed: workingLocationProperties bug scenario fixed")
93
-
94
- print("\n🎉 All tests passed! Schema parser is working correctly.")
95
- return True
96
-
97
-
98
-if __name__ == "__main__":
99
- try:
100
- test_basic_functionality()
101
- print("\n✅ SUCCESS: All schema parser tests passed!")
102
- exit(0)
103
- except Exception as e:
104
- print(f"\n❌ FAILED: Test failed with error: {e}")
105
- import traceback
106
- traceback.print_exc()
107
- exit(1)