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 21, 03:37 UTC
| 1 | """Cross-entry-point checks for primitive JSON Schema conversion.""" |
| 2 | |
| 3 | import pytest |
| 4 | from pydantic import ValidationError |
| 5 | |
| 6 | from composio.utils.shared import pydantic_model_from_param_schema |
| 7 | from tests.fixtures.json_schema_conversion_corpus import find_case |
| 8 | |
| 9 | PRIMITIVE_CASE_IDS = ( |
| 10 | "primitive-boolean-property-schemas", |
| 11 | "primitive-empty-and-null-schemas", |
| 12 | "primitive-type-array-union", |
| 13 | "primitive-null-only-unions", |
| 14 | "primitive-enum-intersects-declared-type", |
| 15 | "primitive-scalar-constraints", |
| 16 | "primitive-independent-numeric-bounds", |
| 17 | "primitive-const-intersects-declared-type", |
| 18 | "primitive-compound-enum-values", |
| 19 | "primitive-const-null-and-false", |
| 20 | "primitive-enum-boolean-number-identity", |
| 21 | "primitive-enum-with-null-member", |
| 22 | "primitive-const-constraint-conjunction", |
| 23 | "primitive-inclusive-numeric-boundaries", |
| 24 | "primitive-const-narrows-enum", |
| 25 | "primitive-compound-const-deep-equality", |
| 26 | "primitive-unicode-code-point-length", |
| 27 | "primitive-typeless-constraint-scoping", |
| 28 | "primitive-float-multiple-of", |
| 29 | "primitive-draft4-boolean-exclusive-bounds", |
| 30 | "primitive-type-array-constraint-scoping", |
| 31 | "primitive-empty-enum-optional-property", |
| 32 | ) |
| 33 | |
| 34 | |
| 35 | @pytest.mark.parametrize("case_id", PRIMITIVE_CASE_IDS) |
| 36 | def test_legacy_model_entry_point_matches_shared_primitive_corpus(case_id: str) -> None: |
| 37 | case = find_case(case_id) |
| 38 | model = pydantic_model_from_param_schema( |
| 39 | {**case.schema_, "title": f"Primitive_{case_id}"} |
| 40 | ) |
| 41 | |
| 42 | for instance in case.instances: |
| 43 | if instance.accepted_for("python"): |
| 44 | model.model_validate(instance.input) |
| 45 | else: |
| 46 | with pytest.raises(ValidationError): |
| 47 | model.model_validate(instance.input) |