"""Health and version API tests."""

from __future__ import annotations

import pytest
from fastapi.testclient import TestClient


class TestHealthCheck:
    """Test health check endpoints."""

    def test_health_check_success(
        self,
        test_client: TestClient,
    ):
        """Verify health endpoint returns 200."""
        response = test_client.get("/health")
        
        assert response.status_code == 200
        data = response.json()
        assert "status" in data
        assert data["status"] == "ok"

    def test_health_check_database_connection(
        self,
        test_client: TestClient,
    ):
        """Verify DB connection check."""
        # Basic health check doesn't necessarily check DB
        # This is a placeholder for future DB health checks
        response = test_client.get("/health")
        
        assert response.status_code == 200


class TestVersionEndpoint:
    """Test version endpoint."""

    def test_version_endpoint_success(
        self,
        test_client: TestClient,
    ):
        """Verify version information."""
        response = test_client.get("/version")
        
        assert response.status_code == 200
        data = response.json()
        assert "version" in data or "app_version" in data

    def test_version_endpoint_includes_app_version(
        self,
        test_client: TestClient,
    ):
        """Verify version format."""
        response = test_client.get("/version")
        
        assert response.status_code == 200
        data = response.json()
        # Version should be a string
        version_key = "version" if "version" in data else "app_version"
        assert isinstance(data[version_key], str)

