Files
orion/tests/integration/api/v1/test_stats_endpoints.py

36 lines
1.3 KiB
Python

# tests/integration/api/v1/test_stats_endpoints.py
import pytest
@pytest.mark.integration
@pytest.mark.api
@pytest.mark.stats
class TestStatsAPI:
def test_get_basic_stats(self, client, auth_headers, test_marketplace_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_vendors" in data
assert data["total_products"] >= 1
def test_get_marketplace_stats(self, client, auth_headers, test_marketplace_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