Buckets:

download
raw
6.27 kB
"""Codex-generated unit tests for low-coverage core modules."""
from __future__ import annotations
import inspect
import pytest
class TestAPIMain:
"""Tests for api.main imports and basic app endpoints."""
def test_import_api_main_app(self):
"""Import FastAPI app from api.main."""
try:
from api.main import app
except Exception as exc:
pytest.skip(f"api.main import unavailable: {exc}")
assert app is not None
def test_api_main_has_routes(self):
"""Validate app has at least one route."""
try:
from api.main import app
except Exception as exc:
pytest.skip(f"api.main import unavailable: {exc}")
assert len(app.routes) > 0
def test_api_openapi_endpoint(self):
"""Call the default OpenAPI endpoint."""
try:
from fastapi.testclient import TestClient
from api.main import app
except Exception as exc:
pytest.skip(f"FastAPI/TestClient unavailable: {exc}")
client = TestClient(app)
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.json() is not None
def test_api_docs_endpoint(self):
"""Call the default docs endpoint."""
try:
from fastapi.testclient import TestClient
from api.main import app
except Exception as exc:
pytest.skip(f"FastAPI/TestClient unavailable: {exc}")
client = TestClient(app)
response = client.get("/docs")
assert response.status_code in {200, 404}
class TestAutonomousAgentLoop:
"""Tests for autonomous.agent_loop imports and instantiation."""
def test_import_autonomous_agent_loop(self):
"""Import AutonomousAgentLoop class."""
try:
from autonomous.agent_loop import AutonomousAgentLoop
except Exception as exc:
pytest.skip(f"AutonomousAgentLoop import unavailable: {exc}")
assert inspect.isclass(AutonomousAgentLoop)
def test_instantiate_autonomous_agent_loop(self):
"""Instantiate AutonomousAgentLoop with defaults."""
try:
from autonomous.agent_loop import AutonomousAgentLoop
except Exception as exc:
pytest.skip(f"AutonomousAgentLoop import unavailable: {exc}")
loop = AutonomousAgentLoop()
assert loop is not None
def test_autonomous_agent_loop_has_run_method(self):
"""Verify loop exposes a run-like callable method."""
try:
from autonomous.agent_loop import AutonomousAgentLoop
except Exception as exc:
pytest.skip(f"AutonomousAgentLoop import unavailable: {exc}")
loop = AutonomousAgentLoop()
run_method = getattr(loop, "run", None)
assert callable(run_method)
class TestCoreHealthCheck:
"""Tests for core.health_check imports and basic behavior."""
def test_import_core_health_check_runner(self):
"""Import HealthCheckRunner from core.health_check."""
try:
from core.health_check import HealthCheckRunner
except Exception as exc:
pytest.skip(f"HealthCheckRunner import unavailable: {exc}")
assert inspect.isclass(HealthCheckRunner)
def test_import_core_health_check_functions(self):
"""Import top-level health check functions."""
try:
from core.health_check import (
check_api_health,
check_database,
run_health_check,
)
except Exception as exc:
pytest.skip(f"health check functions unavailable: {exc}")
assert callable(check_database)
assert callable(check_api_health)
assert callable(run_health_check)
def test_instantiate_health_check_runner(self):
"""Instantiate HealthCheckRunner with defaults."""
try:
from core.health_check import HealthCheckRunner
except Exception as exc:
pytest.skip(f"HealthCheckRunner import unavailable: {exc}")
runner = HealthCheckRunner()
assert runner is not None
def test_health_status_enum_has_members(self):
"""Validate HealthStatus enum has values."""
try:
from core.health_check import HealthStatus
except Exception as exc:
pytest.skip(f"HealthStatus import unavailable: {exc}")
assert len(list(HealthStatus)) > 0
class TestToolsNmapIntegration:
"""Tests for tools.nmap_integration imports and instantiation."""
def test_import_nmap_scanner(self):
"""Import NmapScanner from tools.nmap_integration."""
try:
from tools.nmap_integration import NmapScanner
except Exception as exc:
pytest.skip(f"NmapScanner import unavailable: {exc}")
assert inspect.isclass(NmapScanner)
def test_instantiate_nmap_scanner(self):
"""Instantiate NmapScanner with defaults."""
try:
from tools.nmap_integration import NmapScanner
except Exception as exc:
pytest.skip(f"NmapScanner import unavailable: {exc}")
try:
scanner = NmapScanner(target="scanme.nmap.org")
except Exception as exc:
pytest.skip(f"NmapScanner instantiation unavailable: {exc}")
assert scanner is not None
def test_nmap_scanner_has_scan_target_method(self):
"""Verify NmapScanner exposes scan_target method."""
try:
from tools.nmap_integration import NmapScanner
except Exception as exc:
pytest.skip(f"NmapScanner import unavailable: {exc}")
try:
scanner = NmapScanner(target="scanme.nmap.org")
except Exception as exc:
pytest.skip(f"NmapScanner instantiation unavailable: {exc}")
scan_target = getattr(scanner, "scan_target", None)
assert callable(scan_target)
def test_nmap_scan_type_enum_has_members(self):
"""Validate ScanType enum has values."""
try:
from tools.nmap_integration import ScanType
except Exception as exc:
pytest.skip(f"ScanType import unavailable: {exc}")
assert len(list(ScanType)) > 0

Xet Storage Details

Size:
6.27 kB
·
Xet hash:
6a4b9aadf5573b552d56f67f80c2c5102431ff9916d60938521459c6f6c57d2d

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