"""
Integration tests for the AI Feedback FastAPI application.
"""

import pytest
from fastapi.testclient import TestClient


class TestAPIIntegration:
    """Integration tests for the API endpoints."""

    def test_health_check_integration(self, client: TestClient):
        """Test the complete health check flow."""
        response = client.get("/api/v1/health/health")
        assert response.status_code == 200

        data = response.json()
        assert "status" in data
        assert "timestamp" in data
        assert "checks" in data

    def test_error_handling_integration(self, client: TestClient):
        """Test error handling for non-existent endpoints."""
        response = client.get("/non-existent-endpoint")
        assert response.status_code == 404


class TestQueueIntegration:
    """Integration tests for queue operations."""

    def test_queue_status_integration(self, client: TestClient):
        """Test queue status endpoint."""
        response = client.get("/api/v1/queue/status")
        assert response.status_code == 200

        data = response.json()
        assert "total_jobs" in data
        assert "pending_jobs" in data
        assert "processing_jobs" in data

    def test_queue_process_integration(self, client: TestClient):
        """Test queue process endpoint."""
        response = client.post("/api/v1/queue/process")
        assert response.status_code == 200

        data = response.json()
        assert "message" in data


class TestServiceIntegration:
    """Integration tests for service layer."""

    @pytest.mark.asyncio
    async def test_health_service_integration(self):
        """Test health service integration."""
        from app.services.health import HealthService

        health_service = HealthService()
        health_result = await health_service.check_all()
        assert "status" in health_result
        assert "checks" in health_result
