Buckets:

download
raw
3.95 kB
"""
Basic Unit Tests for Tool Integrations
"""
from unittest.mock import MagicMock, patch
import pytest
class TestToolImports:
"""Test that tools can be imported"""
def test_import_tools_module(self):
"""Test tools module imports"""
import tools
assert tools is not None
def test_tool_registry_exists(self):
"""Test tool registry exists"""
from tools import TOOL_REGISTRY
assert isinstance(TOOL_REGISTRY, dict)
def test_nmap_scan_in_registry(self):
"""Test nmap_scan is in registry"""
from tools import TOOL_REGISTRY
assert "nmap_scan" in TOOL_REGISTRY
def test_sqlmap_scan_in_registry(self):
"""Test sqlmap_scan is in registry"""
from tools import TOOL_REGISTRY
assert "sqlmap_scan" in TOOL_REGISTRY
def test_nuclei_scan_in_registry(self):
"""Test nuclei_scan is in registry"""
from tools import TOOL_REGISTRY
assert "nuclei_scan" in TOOL_REGISTRY
class TestToolBasics:
"""Test basic tool functionality"""
def test_nmap_scan_callable(self):
"""Test nmap_scan is callable"""
from tools import TOOL_REGISTRY
nmap = TOOL_REGISTRY.get("nmap_scan")
assert nmap is not None
def test_sqlmap_scan_callable(self):
"""Test sqlmap_scan is callable"""
from tools import TOOL_REGISTRY
sqlmap = TOOL_REGISTRY.get("sqlmap_scan")
assert sqlmap is not None
def test_nuclei_scan_callable(self):
"""Test nuclei_scan is callable"""
from tools import TOOL_REGISTRY
nuclei = TOOL_REGISTRY.get("nuclei_scan")
assert nuclei is not None
class TestToolResults:
"""Test tool result handling"""
def test_result_object_access(self):
"""Test accessing result object attributes"""
from dataclasses import dataclass
@dataclass
class MockResult:
target: str
status: str
result = MockResult(target="test.com", status="success")
assert result.target == "test.com"
assert result.status == "success"
def test_result_dict_access(self):
"""Test accessing result dict"""
result = {"target": "test.com", "status": "success"}
assert result["target"] == "test.com"
assert result.get("status") == "success"
class TestToolRegistryOperations:
"""Test tool registry operations"""
def test_registry_get(self):
"""Test getting tool from registry"""
from tools import TOOL_REGISTRY
tool = TOOL_REGISTRY.get("nmap_scan")
assert tool is not None
def test_registry_keys(self):
"""Test registry has expected keys"""
from tools import TOOL_REGISTRY
expected_tools = [
"nmap_scan",
"sqlmap_scan",
"nuclei_scan",
"nikto_scan",
]
for tool_name in expected_tools:
assert tool_name in TOOL_REGISTRY or tool_name.replace("_scan", "") in str(TOOL_REGISTRY.keys())
def test_registry_length(self):
"""Test registry has tools"""
from tools import TOOL_REGISTRY
assert len(TOOL_REGISTRY) > 0
class TestToolFunctionSignatures:
"""Test tool function signatures"""
def test_nmap_has_target_param(self):
"""Test nmap has target parameter"""
from tools import TOOL_REGISTRY
nmap = TOOL_REGISTRY.get("nmap_scan")
if hasattr(nmap, "args_schema"):
# It's a StructuredTool
assert nmap is not None
else:
import inspect
sig = inspect.signature(nmap)
assert "target" in sig.parameters or "url" in sig.parameters
def test_sqlmap_has_url_param(self):
"""Test sqlmap has url parameter"""
from tools import TOOL_REGISTRY
sqlmap = TOOL_REGISTRY.get("sqlmap_scan")
assert sqlmap is not None

Xet Storage Details

Size:
3.95 kB
·
Xet hash:
084c10050707e8aaed49157ec2d84a8115743a53ec80412970f14ab539cb685f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.