"""Test Pro analyzer."""

from pathlib import Path

from apiposture_pro.analysis.pro_analyzer import ProAnalyzer


def test_pro_analyzer_initialization() -> None:
    """Test Pro analyzer can be initialized."""
    analyzer = ProAnalyzer()
    assert analyzer is not None
    assert analyzer.analyzer is not None


def test_pro_analyzer_analyze_simple_project(temp_dir: Path) -> None:
    """Test Pro analyzer can analyze a simple project."""
    # Create a minimal FastAPI project
    project_dir = temp_dir / "test_project"
    project_dir.mkdir()

    app_file = project_dir / "main.py"
    app_file.write_text("""
from fastapi import FastAPI

app = FastAPI()

@app.get("/health")
async def health():
    return {"status": "ok"}
""")

    analyzer = ProAnalyzer()
    result = analyzer.analyze(project_dir)

    # Should find at least one endpoint
    assert result is not None
    assert len(result.endpoints) >= 1


def test_pro_analyzer_handles_empty_project(temp_dir: Path) -> None:
    """Test Pro analyzer handles empty projects gracefully."""
    empty_dir = temp_dir / "empty"
    empty_dir.mkdir()

    analyzer = ProAnalyzer()
    result = analyzer.analyze(empty_dir)

    # Should return result with no endpoints or findings
    assert result is not None
    assert len(result.endpoints) == 0
