Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/workato_platform_cli/client/workato_api/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions tests/unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Model validation tests
59 changes: 59 additions & 0 deletions tests/unit/models/test_asset.py
Original file line number Diff line number Diff line change
@@ -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)
55 changes: 55 additions & 0 deletions tests/unit/models/test_asset_reference.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions workato-api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,7 @@ components:
data_pipeline,
decision_engine_model,
agentic_knowledge_base,
mcp_server,
]
example: "recipe"
version:
Expand Down Expand Up @@ -1814,6 +1815,7 @@ components:
data_pipeline,
decision_engine_model,
agentic_knowledge_base,
mcp_server,
]
checked:
type: boolean
Expand Down