"""Quick integration test for the blog API endpoints.""" import sys from pathlib import Path # Add parent to path sys.path.insert(0, str(Path(__file__).parent.parent)) from fastapi.testclient import TestClient from main import app client = TestClient(app) def test_health_check(): """Test the health endpoint.""" response = client.get("/health") assert response.status_code == 200 assert response.json()["status"] == "healthy" def test_root_endpoint(): """Test the root endpoint.""" response = client.get("/") assert response.status_code == 200 assert "HoffDesk" in response.json()["message"] def test_list_posts_empty(): """Test listing posts when none exist.""" response = client.get("/api/blog/posts") assert response.status_code == 200 data = response.json() assert data["posts"] == [] assert data["total"] == 0 def test_search_empty(): """Test search with empty query.""" response = client.get("/api/blog/search?q=test") assert response.status_code == 200 data = response.json() assert data["results"] == [] assert data["total"] == 0 def test_categories_empty(): """Test listing categories when none exist.""" response = client.get("/api/blog/categories") assert response.status_code == 200 data = response.json() assert data["categories"] == [] def test_tags_empty(): """Test listing tags when none exist.""" response = client.get("/api/blog/tags") assert response.status_code == 200 data = response.json() assert data["tags"] == [] if __name__ == "__main__": test_health_check() test_root_endpoint() test_list_posts_empty() test_search_empty() test_categories_empty() test_tags_empty() print("✓ All integration tests passed!")