Skip to content

Commit 831d8a1

Browse files
committed
Test loading templates from valid/invaid URLs and invalid bundle names
1 parent 90fb2c1 commit 831d8a1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

agentstack/cli/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def export_template(output_filename: str, path: str = ''):
517517
if tool_name not in tools_agents:
518518
tools_agents[tool_name] = []
519519
tools_agents[tool_name].append(agent_name)
520-
520+
521521
tools: list[TemplateConfig.Tool] = []
522522
for tool_name, agent_names in tools_agents.items():
523523
tools.append(

tests/test_templates_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
import json
33
import unittest
44
from parameterized import parameterized
5+
from agentstack import ValidationError
56
from agentstack.proj_templates import TemplateConfig, get_all_template_names, get_all_template_paths
67

78
BASE_PATH = Path(__file__).parent
9+
VALID_TEMPLATE_URL = "https://raw.githubusercontent.com/AgentOps-AI/AgentStack/13a6e335fb163b932ed037562fcedbc269f0d5a5/agentstack/templates/proj_templates/content_creator.json"
10+
INVALID_TEMPLATE_URL = "https://raw.githubusercontent.com/AgentOps-AI/AgentStack/13a6e335fb163b932ed037562fcedbc269f0d5a5/tests/fixtures/tool_config_min.json"
811

912

1013
class TemplateConfigTest(unittest.TestCase):
@@ -19,3 +22,15 @@ def test_all_configs_from_template_path(self, template_path: Path):
1922
config = TemplateConfig.from_json(template_path)
2023
assert config.name == template_path.stem
2124
# We can assume that pydantic validation caught any other issues
25+
26+
def test_invalid_template_name(self):
27+
with self.assertRaises(ValidationError):
28+
TemplateConfig.from_template_name("invalid")
29+
30+
def test_load_template_from_valid_url(self):
31+
config = TemplateConfig.from_url(VALID_TEMPLATE_URL)
32+
assert config.name == "content_creator"
33+
34+
def load_template_from_invalid_url(self):
35+
with self.assertRaises(ValidationError):
36+
TemplateConfig.from_url(INVALID_TEMPLATE_URL)

0 commit comments

Comments
 (0)