From c80b727c3803df26b2f6b5a2c2c151f78fbaf43e Mon Sep 17 00:00:00 2001 From: Braelyn Boynton Date: Tue, 28 Jan 2025 16:25:41 -0800 Subject: [PATCH] add version to neon dependency and add check --- agentstack/_tools/neon/config.json | 2 +- tests/test_tool_config.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/agentstack/_tools/neon/config.json b/agentstack/_tools/neon/config.json index e5c59384..ed860324 100644 --- a/agentstack/_tools/neon/config.json +++ b/agentstack/_tools/neon/config.json @@ -7,7 +7,7 @@ }, "dependencies": [ "neon-api>=0.1.5", - "psycopg2-binary" + "psycopg2-binary==2.9.10" ], "tools": ["create_database", "execute_sql_ddl", "run_sql_query"], "cta": "Create an API key at https://www.neon.tech" diff --git a/tests/test_tool_config.py b/tests/test_tool_config.py index f86823d4..bf187e44 100644 --- a/tests/test_tool_config.py +++ b/tests/test_tool_config.py @@ -1,11 +1,11 @@ import json import unittest +import re from pathlib import Path from agentstack._tools import ToolConfig, get_all_tool_paths, get_all_tool_names BASE_PATH = Path(__file__).parent - class ToolConfigTest(unittest.TestCase): def test_minimal_json(self): config = ToolConfig.from_json(BASE_PATH / "fixtures/tool_config_min.json") @@ -29,6 +29,20 @@ def test_maximal_json(self): assert config.post_install == "install.sh" assert config.post_remove == "remove.sh" + def test_dependency_versions(self): + """Test that all dependencies specify a version constraint.""" + for tool_name in get_all_tool_names(): + config = ToolConfig.from_tool_name(tool_name) + + if hasattr(config, 'dependencies') and config.dependencies: + version_pattern = r'[><=~!]=|[@><=~!]' + for dep in config.dependencies: + if not re.search(version_pattern, dep): + raise AssertionError( + f"Dependency '{dep}' in {config.name} does not specify a version constraint. " + "All dependencies must include version specifications." + ) + def test_all_json_configs_from_tool_name(self): for tool_name in get_all_tool_names(): config = ToolConfig.from_tool_name(tool_name) @@ -41,8 +55,8 @@ def test_all_json_configs_from_tool_path(self): config = ToolConfig.from_json(f"{path}/config.json") except json.decoder.JSONDecodeError: raise Exception( - f"Failed to decode tool json at {path}. Does your tool config fit the required formatting? https://github.com/AgentOps-AI/AgentStack/blob/main/agentstack/tools/~README.md" + f"Failed to decode tool json at {path}. Does your tool config fit the required formatting? " + "https://github.com/AgentOps-AI/AgentStack/blob/main/agentstack/tools/~README.md" ) assert config.name == path.stem - # We can assume that pydantic validation caught any other issues