diff --git a/src/workato_platform_cli/client/workato_api/models/asset.py b/src/workato_platform_cli/client/workato_api/models/asset.py index 16f05b5..06f091a 100644 --- a/src/workato_platform_cli/client/workato_api/models/asset.py +++ b/src/workato_platform_cli/client/workato_api/models/asset.py @@ -42,8 +42,8 @@ class Asset(BaseModel): @field_validator('type') def type_validate_enum(cls, value): """Validates the enum""" - if value not in set(['recipe', 'connection', 'lookup_table', 'workato_db_table', 'account_property', 'project_property', 'workato_schema', 'workato_template', 'lcap_app', 'lcap_page', 'custom_adapter', 'topic', 'api_group', 'api_endpoint', 'agentic_genie', 'agentic_skill', 'data_pipeline', 'decision_engine_model', 'agentic_knowledge_base']): - raise ValueError("must be one of enum values ('recipe', 'connection', 'lookup_table', 'workato_db_table', 'account_property', 'project_property', 'workato_schema', 'workato_template', 'lcap_app', 'lcap_page', 'custom_adapter', 'topic', 'api_group', 'api_endpoint', 'agentic_genie', 'agentic_skill', 'data_pipeline', 'decision_engine_model', 'agentic_knowledge_base')") + if value not in set(['recipe', 'connection', 'lookup_table', 'workato_db_table', 'account_property', 'project_property', 'workato_schema', 'workato_template', 'lcap_app', 'lcap_page', 'custom_adapter', 'topic', 'api_group', 'api_endpoint', 'agentic_genie', 'agentic_skill', 'data_pipeline', 'decision_engine_model', 'agentic_knowledge_base', 'mcp_server']): + raise ValueError("must be one of enum values ('recipe', 'connection', 'lookup_table', 'workato_db_table', 'account_property', 'project_property', 'workato_schema', 'workato_template', 'lcap_app', 'lcap_page', 'custom_adapter', 'topic', 'api_group', 'api_endpoint', 'agentic_genie', 'agentic_skill', 'data_pipeline', 'decision_engine_model', 'agentic_knowledge_base', 'mcp_server')") return value @field_validator('status') diff --git a/src/workato_platform_cli/client/workato_api/models/asset_reference.py b/src/workato_platform_cli/client/workato_api/models/asset_reference.py index dcceea4..04d9a57 100644 --- a/src/workato_platform_cli/client/workato_api/models/asset_reference.py +++ b/src/workato_platform_cli/client/workato_api/models/asset_reference.py @@ -40,8 +40,8 @@ class AssetReference(BaseModel): @field_validator('type') def type_validate_enum(cls, value): """Validates the enum""" - if value not in set(['recipe', 'connection', 'lookup_table', 'workato_db_table', 'account_property', 'project_property', 'workato_schema', 'workato_template', 'lcap_app', 'lcap_page', 'custom_adapter', 'topic', 'api_group', 'api_endpoint', 'agentic_genie', 'agentic_skill', 'data_pipeline', 'decision_engine_model', 'agentic_knowledge_base']): - raise ValueError("must be one of enum values ('recipe', 'connection', 'lookup_table', 'workato_db_table', 'account_property', 'project_property', 'workato_schema', 'workato_template', 'lcap_app', 'lcap_page', 'custom_adapter', 'topic', 'api_group', 'api_endpoint', 'agentic_genie', 'agentic_skill', 'data_pipeline', 'decision_engine_model', 'agentic_knowledge_base')") + if value not in set(['recipe', 'connection', 'lookup_table', 'workato_db_table', 'account_property', 'project_property', 'workato_schema', 'workato_template', 'lcap_app', 'lcap_page', 'custom_adapter', 'topic', 'api_group', 'api_endpoint', 'agentic_genie', 'agentic_skill', 'data_pipeline', 'decision_engine_model', 'agentic_knowledge_base', 'mcp_server']): + raise ValueError("must be one of enum values ('recipe', 'connection', 'lookup_table', 'workato_db_table', 'account_property', 'project_property', 'workato_schema', 'workato_template', 'lcap_app', 'lcap_page', 'custom_adapter', 'topic', 'api_group', 'api_endpoint', 'agentic_genie', 'agentic_skill', 'data_pipeline', 'decision_engine_model', 'agentic_knowledge_base', 'mcp_server')") return value model_config = ConfigDict( diff --git a/tests/unit/models/__init__.py b/tests/unit/models/__init__.py new file mode 100644 index 0000000..f10bf98 --- /dev/null +++ b/tests/unit/models/__init__.py @@ -0,0 +1 @@ +# Model validation tests diff --git a/tests/unit/models/test_asset.py b/tests/unit/models/test_asset.py new file mode 100644 index 0000000..26d6f92 --- /dev/null +++ b/tests/unit/models/test_asset.py @@ -0,0 +1,59 @@ +import pytest + +from workato_platform_cli.client.workato_api.models.asset import Asset + + +def test_asset_accepts_all_valid_types() -> None: + """Test that Asset model accepts all valid asset types.""" + valid_types = [ + "recipe", + "connection", + "lookup_table", + "workato_db_table", + "account_property", + "project_property", + "workato_schema", + "workato_template", + "lcap_app", + "lcap_page", + "custom_adapter", + "topic", + "api_group", + "api_endpoint", + "agentic_genie", + "agentic_skill", + "data_pipeline", + "decision_engine_model", + "agentic_knowledge_base", + "mcp_server", + ] + + for asset_type in valid_types: + asset_data = { + "id": 1, + "name": f"Test {asset_type}", + "type": asset_type, + "zip_name": "test.zip", + "checked": True, + "root_folder": False, + } + + # Should not raise ValueError + asset = Asset.from_dict(asset_data) + assert asset is not None + assert asset.type == asset_type + + +def test_asset_rejects_invalid_type() -> None: + """Test that Asset model rejects invalid types.""" + asset_data = { + "id": 12345, + "name": "Test Asset", + "type": "invalid_type", + "zip_name": "test.zip", + "checked": True, + "root_folder": False, + } + + with pytest.raises(ValueError, match="must be one of enum values"): + Asset.from_dict(asset_data) diff --git a/tests/unit/models/test_asset_reference.py b/tests/unit/models/test_asset_reference.py new file mode 100644 index 0000000..69c0b8a --- /dev/null +++ b/tests/unit/models/test_asset_reference.py @@ -0,0 +1,55 @@ +import pytest + +from workato_platform_cli.client.workato_api.models.asset_reference import ( + AssetReference, +) + + +def test_asset_reference_accepts_all_valid_types() -> None: + """Test that AssetReference model accepts all valid asset types.""" + valid_types = [ + "recipe", + "connection", + "lookup_table", + "workato_db_table", + "account_property", + "project_property", + "workato_schema", + "workato_template", + "lcap_app", + "lcap_page", + "custom_adapter", + "topic", + "api_group", + "api_endpoint", + "agentic_genie", + "agentic_skill", + "data_pipeline", + "decision_engine_model", + "agentic_knowledge_base", + "mcp_server", + ] + + for asset_type in valid_types: + asset_ref_data = { + "id": 1, + "type": asset_type, + "absolute_path": f"/test/{asset_type}", + } + + # Should not raise ValueError + asset_ref = AssetReference.from_dict(asset_ref_data) + assert asset_ref is not None + assert asset_ref.type == asset_type + + +def test_asset_reference_rejects_invalid_type() -> None: + """Test that AssetReference model rejects invalid types.""" + asset_ref_data = { + "id": 12345, + "type": "invalid_type", + "absolute_path": "/test/invalid", + } + + with pytest.raises(ValueError, match="must be one of enum values"): + AssetReference.from_dict(asset_ref_data) diff --git a/workato-api-spec.yaml b/workato-api-spec.yaml index 28360cc..c909859 100644 --- a/workato-api-spec.yaml +++ b/workato-api-spec.yaml @@ -1703,6 +1703,7 @@ components: data_pipeline, decision_engine_model, agentic_knowledge_base, + mcp_server, ] example: "recipe" version: @@ -1814,6 +1815,7 @@ components: data_pipeline, decision_engine_model, agentic_knowledge_base, + mcp_server, ] checked: type: boolean