shop product refactoring

This commit is contained in:
2025-10-04 23:38:53 +02:00
parent 4d2866af5e
commit 0114b6c46e
68 changed files with 2234 additions and 2236 deletions

View File

@@ -2,7 +2,7 @@
import pytest
from models.database.marketplace_product import MarketplaceProduct
from models.database.shop import Shop
from models.database.vendor import Vendor
@pytest.mark.integration
@pytest.mark.api
@@ -181,34 +181,34 @@ class TestPagination:
overlap = set(first_page_ids) & set(second_page_ids)
assert len(overlap) == 0, "Pages should not have overlapping products"
def test_shop_pagination_success(self, client, admin_headers, db, test_user):
"""Test pagination for shop listing successfully"""
def test_vendor_pagination_success(self, client, admin_headers, db, test_user):
"""Test pagination for vendor listing successfully"""
import uuid
unique_suffix = str(uuid.uuid4())[:8]
# Create multiple shops for pagination testing
from models.database.shop import Shop
shops = []
# Create multiple vendors for pagination testing
from models.database.vendor import Vendor
vendors =[]
for i in range(15):
shop = Shop(
shop_code=f"PAGESHOP{i:03d}_{unique_suffix}",
shop_name=f"Pagination Shop {i}",
vendor = Vendor(
vendor_code=f"PAGESHOP{i:03d}_{unique_suffix}",
vendor_name=f"Pagination Vendor {i}",
owner_id=test_user.id,
is_active=True,
)
shops.append(shop)
vendors.append(vendor)
db.add_all(shops)
db.add_all(vendors)
db.commit()
# Test first page (assuming admin endpoint exists)
response = client.get(
"/api/v1/shop?limit=5&skip=0", headers=admin_headers
"/api/v1/vendor ?limit=5&skip=0", headers=admin_headers
)
assert response.status_code == 200
data = response.json()
assert len(data["shops"]) == 5
assert data["total"] >= 15 # At least our test shops
assert len(data["vendors"]) == 5
assert data["total"] >= 15 # At least our test vendors
assert data["skip"] == 0
assert data["limit"] == 5