# tests/test_stats.py import pytest class TestStatsAPI: def test_get_basic_stats(self, client, auth_headers, test_product): """Test getting basic statistics""" response = client.get("/api/v1/stats", headers=auth_headers) assert response.status_code == 200 data = response.json() assert "total_products" in data assert "unique_brands" in data assert "unique_categories" in data assert "unique_marketplaces" in data assert "unique_shops" in data assert data["total_products"] >= 1 def test_get_marketplace_stats(self, client, auth_headers, test_product): """Test getting marketplace statistics""" response = client.get("/api/v1/stats/marketplace", headers=auth_headers) assert response.status_code == 200 data = response.json() assert isinstance(data, list) if len(data) > 0: assert "marketplace" in data[0] assert "total_products" in data[0] def test_get_stats_without_auth(self, client): """Test that stats endpoints require authentication""" response = client.get("/api/v1/stats") assert response.status_code == 401 # No authorization header