Tests restructuring
This commit is contained in:
33
tests/integration/api/v1/test_stats_endpoints.py
Normal file
33
tests/integration/api/v1/test_stats_endpoints.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# tests/test_stats_endpoints.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
|
||||
Reference in New Issue
Block a user