fix(lint): format hanzo-mcp tests with ruff

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
zooqueen
2026-02-21 23:37:18 -08:00
co-authored by Hanzo Dev
parent b144973bfc
commit c14176a266
8 changed files with 44 additions and 41 deletions
+3 -3
View File
@@ -440,9 +440,9 @@ def apply_transformations(record: Any, params: Dict[str, Any]) -> Any:
)
# 3. Benchmark search performance
size_results["search_performance"] = (
await self.benchmark_search_performance(test_project, test_queries)
)
size_results[
"search_performance"
] = await self.benchmark_search_performance(test_project, test_queries)
benchmark_results["results"][size] = size_results
@@ -26,16 +26,16 @@ class TestHiddenFilePermissions:
# Test paths with the fixed implementation
# The workflow example and gitignore files should be allowed
assert manager.is_path_allowed(
problem_path
), "Should allow .github-workflow-example.yml"
assert manager.is_path_allowed(problem_path), (
"Should allow .github-workflow-example.yml"
)
assert manager.is_path_allowed(gitignore_file), "Should allow .gitignore"
assert manager.is_path_allowed(git_related_file), "Should allow git-tutorial.md"
# Since .git is now allowed by default, this should also be allowed
assert manager.is_path_allowed(
actual_github_dir
), "Should allow actual .github directory"
assert manager.is_path_allowed(actual_github_dir), (
"Should allow actual .github directory"
)
def test_various_hidden_files(self, tool_helper, temp_dir: str):
"""Test a variety of hidden files and paths to ensure correct behavior."""
@@ -93,15 +93,15 @@ class TestHiddenFilePermissions:
# Test full component paths (should be excluded)
for path in full_component_paths:
assert not manager.is_path_allowed(
path
), f"Should exclude full component: {path}"
assert not manager.is_path_allowed(path), (
f"Should exclude full component: {path}"
)
# Test partial component paths (should be allowed)
for path in partial_component_paths:
assert manager.is_path_allowed(
path
), f"Should allow partial component: {path}"
assert manager.is_path_allowed(path), (
f"Should allow partial component: {path}"
)
def test_wildcard_patterns(self, tool_helper, temp_dir: str):
"""Test that wildcard patterns work correctly."""
@@ -127,9 +127,9 @@ class TestHiddenFilePermissions:
# Test wildcard matching paths (should be excluded)
for path in wildcard_matches:
assert not manager.is_path_allowed(
path
), f"Should exclude wildcard match: {path}"
assert not manager.is_path_allowed(path), (
f"Should exclude wildcard match: {path}"
)
# Test non-matching paths (should be allowed)
for path in wildcard_non_matches:
+3 -3
View File
@@ -22,9 +22,9 @@ def test_cli_help():
print(f"STDOUT: {result.stdout[:200]}")
print(f"STDERR: {result.stderr[:200]}")
assert (
result.returncode == 0
), f"Command failed with code {result.returncode}\nSTDOUT: {result.stdout}\nSTDERR: {result.stderr}"
assert result.returncode == 0, (
f"Command failed with code {result.returncode}\nSTDOUT: {result.stdout}\nSTDERR: {result.stderr}"
)
assert "hanzo" in result.stdout.lower() or "mcp" in result.stdout.lower()
print("✓ CLI help works")
+6 -6
View File
@@ -15,14 +15,14 @@ def test_no_pydantic_warnings():
)
# Check for deprecation warnings in stderr
assert (
"PydanticDeprecatedSince20" not in result.stderr
), f"Pydantic deprecation warning found in stderr: {result.stderr}"
assert "PydanticDeprecatedSince20" not in result.stderr, (
f"Pydantic deprecation warning found in stderr: {result.stderr}"
)
# Check that the command succeeded
assert (
result.returncode == 0
), f"Command failed with return code {result.returncode}"
assert result.returncode == 0, (
f"Command failed with return code {result.returncode}"
)
# Check that help text is shown
assert "MCP server implementing Hanzo AI capabilities" in result.stdout
@@ -150,9 +150,9 @@ class TestCLIPerformance:
elapsed = time.time() - start
assert result.returncode == 0, f"CLI help failed: {result.stderr}"
assert (
elapsed < MAX_CLI_STARTUP_TIME
), f"CLI --help took {elapsed:.2f}s (max: {MAX_CLI_STARTUP_TIME}s). This is too slow for MCP connections."
assert elapsed < MAX_CLI_STARTUP_TIME, (
f"CLI --help took {elapsed:.2f}s (max: {MAX_CLI_STARTUP_TIME}s). This is too slow for MCP connections."
)
def test_cli_does_not_hang(self):
"""Test that CLI starts without hanging.
+3 -3
View File
@@ -24,9 +24,9 @@ def test_defaults():
or os.environ.get("CLAUDE_API_KEY")
)
assert (
model == "anthropic/claude-3-5-sonnet-20241022"
), f"Expected Claude Sonnet, got {model}"
assert model == "anthropic/claude-3-5-sonnet-20241022", (
f"Expected Claude Sonnet, got {model}"
)
print("✓ Swarm defaults to Claude 3.5 Sonnet")
# Check API key detection
+6 -6
View File
@@ -164,9 +164,9 @@ class ToolTestHelper:
if message:
assert expected in normalized, f"{message}. Got: {normalized}"
else:
assert (
expected in normalized
), f"Expected '{expected}' in result. Got: {normalized}"
assert expected in normalized, (
f"Expected '{expected}' in result. Got: {normalized}"
)
@staticmethod
def assert_success(result: Any):
@@ -174,9 +174,9 @@ class ToolTestHelper:
normalized = ToolTestHelper.normalize_result(result)
error_indicators = ["error", "failed", "exception", "Error:", "Failed:"]
for indicator in error_indicators:
assert (
indicator.lower() not in normalized.lower()
), f"Result indicates error: {normalized}"
assert indicator.lower() not in normalized.lower(), (
f"Result indicates error: {normalized}"
)
class FileSystemTestHelper:
+5 -2
View File
@@ -43,7 +43,8 @@ class TestInfinityVectorStore:
def test_add_file(self, tool_helper, temp_store):
"""Test adding a file with chunking."""
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
f.write("""
f.write(
"""
def hello_world():
'''A simple hello world function.'''
print("Hello, World!")
@@ -63,7 +64,9 @@ class Calculator:
# This is a long comment to test chunking behavior
# when files are larger than the chunk size
# and need to be split into multiple documents
""" * 50) # Make it long enough to require chunking
"""
* 50
) # Make it long enough to require chunking
f.flush()
doc_ids = temp_store.add_file(