marketplace refactoring

This commit is contained in:
2025-10-04 13:38:10 +02:00
parent 32be301d83
commit c971674ec2
68 changed files with 1102 additions and 1128 deletions

View File

@@ -3,7 +3,7 @@ import time
import pytest
from models.database.product import Product
from models.database.marketplace_product import MarketplaceProduct
@pytest.mark.performance
@@ -15,9 +15,9 @@ class TestPerformance:
# Create multiple products
products = []
for i in range(100):
product = Product(
product_id=f"PERF{i:03d}",
title=f"Performance Test Product {i}",
product = MarketplaceProduct(
marketplace_product_id=f"PERF{i:03d}",
title=f"Performance Test MarketplaceProduct {i}",
price=f"{i}.99",
marketplace="Performance",
)
@@ -28,7 +28,7 @@ class TestPerformance:
# Time the request
start_time = time.time()
response = client.get("/api/v1/product?limit=100", headers=auth_headers)
response = client.get("/api/v1/marketplace/product?limit=100", headers=auth_headers)
end_time = time.time()
assert response.status_code == 200
@@ -40,9 +40,9 @@ class TestPerformance:
# Create products with searchable content
products = []
for i in range(50):
product = Product(
product_id=f"SEARCH{i:03d}",
title=f"Searchable Product {i}",
product = MarketplaceProduct(
marketplace_product_id=f"SEARCH{i:03d}",
title=f"Searchable MarketplaceProduct {i}",
description=f"This is a searchable product number {i}",
brand="SearchBrand",
marketplace="SearchMarket",
@@ -54,7 +54,7 @@ class TestPerformance:
# Time search request
start_time = time.time()
response = client.get("/api/v1/product?search=Searchable", headers=auth_headers)
response = client.get("/api/v1/marketplace/product?search=Searchable", headers=auth_headers)
end_time = time.time()
assert response.status_code == 200
@@ -69,9 +69,9 @@ class TestPerformance:
marketplaces = ["Market1", "Market2"]
for i in range(200):
product = Product(
product_id=f"COMPLEX{i:03d}",
title=f"Complex Product {i}",
product = MarketplaceProduct(
marketplace_product_id=f"COMPLEX{i:03d}",
title=f"Complex MarketplaceProduct {i}",
brand=brands[i % 3],
marketplace=marketplaces[i % 2],
price=f"{10 + (i % 50)}.99",
@@ -85,7 +85,7 @@ class TestPerformance:
# Test complex filtering performance
start_time = time.time()
response = client.get(
"/api/v1/product?brand=Brand1&marketplace=Market1&limit=50",
"/api/v1/marketplace/product?brand=Brand1&marketplace=Market1&limit=50",
headers=auth_headers,
)
end_time = time.time()
@@ -100,9 +100,9 @@ class TestPerformance:
# Create a large dataset
products = []
for i in range(500):
product = Product(
product_id=f"LARGE{i:04d}",
title=f"Large Dataset Product {i}",
product = MarketplaceProduct(
marketplace_product_id=f"LARGE{i:04d}",
title=f"Large Dataset MarketplaceProduct {i}",
marketplace="LargeTest",
)
products.append(product)
@@ -115,7 +115,7 @@ class TestPerformance:
for offset in offsets:
start_time = time.time()
response = client.get(
f"/api/v1/product?skip={offset}&limit=20", headers=auth_headers
f"/api/v1/marketplace/product?skip={offset}&limit=20", headers=auth_headers
)
end_time = time.time()