Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
74e8464
feat: add end to end integration test
JackYPCOnline Jun 9, 2025
6910700
Merge branch 'strands-agents:main' into integration-test
JackYPCOnline Jun 10, 2025
42656ba
feat: add integration tests for the package
JackYPCOnline Jun 11, 2025
f24b8fe
feat: remove old test
JackYPCOnline Jun 11, 2025
b4d3cfc
refactor: refactor the test code with patch api instead of monkeypatch
JackYPCOnline Jun 12, 2025
991e70d
feat: add STRANDS_ANTHROPIC_BETA environment variable (#34)
awsarron Jun 18, 2025
a4fed3c
Windows: Remove cron tool + document missing tools when on windows (#33)
zastrowm Jun 19, 2025
88c305d
udpate agent system_prompt reference (#35)
Unshure Jul 3, 2025
2eff5dc
chore: explicitly set load_tools_from_directory on Agent initilizatio…
dbschmigelski Jul 11, 2025
68e2c50
Update builder with updates from 0.3.0 SDK (#39)
zastrowm Jul 11, 2025
577e9f0
chore: Remove Preview (#40)
yonib05 Jul 15, 2025
ac7d801
deps: bump strangs-agents to v1.0.0 (#41)
jer96 Jul 15, 2025
e30a6e9
build(pyproject): update development status classifier (#42)
awsarron Jul 16, 2025
0702a52
Use strands logo that looks good in dark & light mode (#44)
zastrowm Jul 21, 2025
09a19a9
fix: refactor some tests
JackYPCOnline Aug 1, 2025
0dd5163
Merge branch 'strands-agents:main' into integration-test
JackYPCOnline Aug 1, 2025
b0c5f7e
fix: refactor tests code
JackYPCOnline Aug 4, 2025
c149f5b
fix: make tests more accurate
JackYPCOnline Aug 14, 2025
629e722
fix: remove test_custom_load_from_file to avoiding text based respons…
JackYPCOnline Aug 14, 2025
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
Empty file added __init__.py
Empty file.
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ test = [
"hatch test --cover --cov-report term --cov-report html --cov-report xml {args}"
]

test-integ = [
"hatch test tests_integ {args}"
]

[tool.pytest.ini_options]
testpaths = [
"tests"
]

[tool.mypy]
python_version = "3.10"
warn_return_any = true
Expand All @@ -161,7 +170,7 @@ ignore_missing_imports = false

[tool.ruff]
line-length = 120
include = ["src/**/*.py", "tests/**/*.py", "tools/**/*.py"]
include = ["src/**/*.py", "tests/**/*.py", "tools/**/*.py","tests_integ/**/*.py"]

[tool.ruff.lint]
select = [
Expand Down
Empty file added tests_integ/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions tests_integ/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Common fixtures for integration tests."""

from pathlib import Path

import pytest


@pytest.fixture
def tmp_file_structure(tmp_path: Path):
"""Creates a temporary directory structure for tool creation and returns paths."""
tools_dir = tmp_path / ".strands" / "tools"
tools_dir.mkdir(parents=True, exist_ok=True)
return {"tools_dir": tools_dir, "root_dir": tmp_path}
38 changes: 38 additions & 0 deletions tests_integ/test_build_agent_from_specifications.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys
from unittest import mock

from strands import Agent

from strands_agents_builder import strands


def test_build_agent_from_specification_file():
"""Test building agent from specification using semantic creation."""

# Agent specification content
spec_content = """Agent Specification:
- Role: Math Tutor Agent
- Purpose: Help students with basic arithmetic and algebra
- Tools needed: calculator, file_read, current_time
- Create specialized tools for math tutoring
"""

# Simulate: cat agent-spec.txt | strands "Build a specialized agent based on these specifications"
query = f"Build a specialized agent based on these specifications:\n\n{spec_content}"

with mock.patch.object(sys, "argv", ["strands", query]):
strands.main()

# Validate agent
agent = Agent(
load_tools_from_directory=True,
callback_handler=None,
)

# Validate agent was created successfully
assert agent is not None

# Validate agent has exactly 3 specified tools
required_tools = ["calculator", "file_read", "current_time"]
for tool_name in required_tools:
assert hasattr(agent.tool, tool_name), f"Agent missing required tool: {tool_name}"
42 changes: 42 additions & 0 deletions tests_integ/test_semantic_create_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import sys
from unittest import mock

from strands.agent import Agent

from strands_agents_builder import strands


@mock.patch("strands_tools.utils.user_input.get_user_input", return_value="y")
@mock.patch.dict("os.environ", {"STRANDS_TOOL_CONSOLE_MODE": "enabled"})
def test_interactive_model_create_tool_then_validate(mock_get_user_input, capsys, tmp_file_structure):
"""
Test creating a calculator tool via CLI and validating its functionality.
"""
with mock.patch.dict("os.environ", {"STRANDS_TOOLS_DIR": str(tmp_file_structure["tools_dir"])}):
test_query = "create a tool that can only calculate sum of two number called calculator"

with mock.patch.object(sys, "argv", ["strands", test_query]):
strands.main()

agent = Agent(
load_tools_from_directory=True,
)

# assert agent has a tool called calculator
assert hasattr(agent.tool, "calculator"), "Agent should have a 'calculator' tool after creation."

test_cases = [("what is 1 plus 2?", "3"), ("calculate 5 plus 7", "12")]

for question, expected in test_cases:
response = agent(question)
response_str = str(response).lower()
assert expected in response_str, f"Expected '{expected}' in response for '{question}', got '{response_str}'"

# Verify the calculator tool was actually used by checking for toolResults
calculator_used = any(
content.get("toolUse", {}).get("name") == "calculator"
for message in agent.messages
for content in message.get("content", [])
if content.get("toolUse")
)
assert calculator_used, f"Calculator tool should have been used for question: '{question}'"
18 changes: 18 additions & 0 deletions tests_integ/test_shell_then_exit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from unittest import mock

from strands_agents_builder import strands


@mock.patch.object(strands, "get_user_input")
@mock.patch.dict("os.environ", {"STRANDS_TOOL_CONSOLE_MODE": "enabled"})
def test_cli_shell_and_interactive_mode(mock_user_input, capsys):
"""Test interactive mode with a shell command."""

user_inputs = ["!echo hello", "exit"]
mock_user_input.side_effect = user_inputs

strands.main()
out = capsys.readouterr().out

assert "hello" in out, "Expected 'hello' (from echo) in output"
assert "thank you for using strands" in out.lower(), "Expected exit message"
Loading