style: apply black and isort formatting across entire codebase

- Standardize quote style (single to double quotes)
- Reorder and group imports alphabetically
- Fix line breaks and indentation for consistency
- Apply PEP 8 formatting standards

Also updated Makefile to exclude both venv and .venv from code quality checks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-28 19:30:17 +01:00
parent 13f0094743
commit 21c13ca39b
236 changed files with 8450 additions and 6545 deletions

View File

@@ -4,6 +4,7 @@ import pytest
from models.database.marketplace_product import MarketplaceProduct
from models.database.vendor import Vendor
@pytest.mark.integration
@pytest.mark.api
@pytest.mark.database
@@ -13,6 +14,7 @@ class TestPagination:
def test_product_pagination_success(self, client, auth_headers, db):
"""Test pagination for product listing successfully"""
import uuid
unique_suffix = str(uuid.uuid4())[:8]
# Create multiple products
@@ -29,7 +31,9 @@ class TestPagination:
db.commit()
# Test first page
response = client.get("/api/v1/marketplace/product?limit=10&skip=0", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?limit=10&skip=0", headers=auth_headers
)
assert response.status_code == 200
data = response.json()
assert len(data["products"]) == 10
@@ -38,21 +42,29 @@ class TestPagination:
assert data["limit"] == 10
# Test second page
response = client.get("/api/v1/marketplace/product?limit=10&skip=10", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?limit=10&skip=10", headers=auth_headers
)
assert response.status_code == 200
data = response.json()
assert len(data["products"]) == 10
assert data["skip"] == 10
# Test last page (should have remaining products)
response = client.get("/api/v1/marketplace/product?limit=10&skip=20", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?limit=10&skip=20", headers=auth_headers
)
assert response.status_code == 200
data = response.json()
assert len(data["products"]) >= 5 # At least 5 remaining from our test set
def test_pagination_boundary_negative_skip_validation_error(self, client, auth_headers):
def test_pagination_boundary_negative_skip_validation_error(
self, client, auth_headers
):
"""Test negative skip parameter returns ValidationException"""
response = client.get("/api/v1/marketplace/product?skip=-1", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?skip=-1", headers=auth_headers
)
assert response.status_code == 422
data = response.json()
@@ -61,9 +73,13 @@ class TestPagination:
assert "Request validation failed" in data["message"]
assert "validation_errors" in data["details"]
def test_pagination_boundary_zero_limit_validation_error(self, client, auth_headers):
def test_pagination_boundary_zero_limit_validation_error(
self, client, auth_headers
):
"""Test zero limit parameter returns ValidationException"""
response = client.get("/api/v1/marketplace/product?limit=0", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?limit=0", headers=auth_headers
)
assert response.status_code == 422
data = response.json()
@@ -71,9 +87,13 @@ class TestPagination:
assert data["status_code"] == 422
assert "Request validation failed" in data["message"]
def test_pagination_boundary_excessive_limit_validation_error(self, client, auth_headers):
def test_pagination_boundary_excessive_limit_validation_error(
self, client, auth_headers
):
"""Test excessive limit parameter returns ValidationException"""
response = client.get("/api/v1/marketplace/product?limit=10000", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?limit=10000", headers=auth_headers
)
assert response.status_code == 422
data = response.json()
@@ -84,7 +104,9 @@ class TestPagination:
def test_pagination_beyond_available_records(self, client, auth_headers, db):
"""Test pagination beyond available records returns empty results"""
# Test skip beyond available records
response = client.get("/api/v1/marketplace/product?skip=10000&limit=10", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?skip=10000&limit=10", headers=auth_headers
)
assert response.status_code == 200
data = response.json()
@@ -96,6 +118,7 @@ class TestPagination:
def test_pagination_with_filters(self, client, auth_headers, db):
"""Test pagination combined with filtering"""
import uuid
unique_suffix = str(uuid.uuid4())[:8]
# Create products with same brand for filtering
@@ -115,7 +138,7 @@ class TestPagination:
# Test first page with filter
response = client.get(
"/api/v1/marketplace/product?brand=FilterBrand&limit=5&skip=0",
headers=auth_headers
headers=auth_headers,
)
assert response.status_code == 200
@@ -124,14 +147,18 @@ class TestPagination:
assert data["total"] >= 15 # At least our test products
# Verify all products have the filtered brand
test_products = [p for p in data["products"] if p["marketplace_product_id"].endswith(unique_suffix)]
test_products = [
p
for p in data["products"]
if p["marketplace_product_id"].endswith(unique_suffix)
]
for product in test_products:
assert product["brand"] == "FilterBrand"
# Test second page with same filter
response = client.get(
"/api/v1/marketplace/product?brand=FilterBrand&limit=5&skip=5",
headers=auth_headers
headers=auth_headers,
)
assert response.status_code == 200
@@ -152,6 +179,7 @@ class TestPagination:
def test_pagination_consistency(self, client, auth_headers, db):
"""Test pagination consistency across multiple requests"""
import uuid
unique_suffix = str(uuid.uuid4())[:8]
# Create products with predictable ordering
@@ -168,14 +196,22 @@ class TestPagination:
db.commit()
# Get first page
response1 = client.get("/api/v1/marketplace/product?limit=5&skip=0", headers=auth_headers)
response1 = client.get(
"/api/v1/marketplace/product?limit=5&skip=0", headers=auth_headers
)
assert response1.status_code == 200
first_page_ids = [p["marketplace_product_id"] for p in response1.json()["products"]]
first_page_ids = [
p["marketplace_product_id"] for p in response1.json()["products"]
]
# Get second page
response2 = client.get("/api/v1/marketplace/product?limit=5&skip=5", headers=auth_headers)
response2 = client.get(
"/api/v1/marketplace/product?limit=5&skip=5", headers=auth_headers
)
assert response2.status_code == 200
second_page_ids = [p["marketplace_product_id"] for p in response2.json()["products"]]
second_page_ids = [
p["marketplace_product_id"] for p in response2.json()["products"]
]
# Verify no overlap between pages
overlap = set(first_page_ids) & set(second_page_ids)
@@ -184,11 +220,13 @@ class TestPagination:
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 vendors for pagination testing
from models.database.vendor import Vendor
vendors =[]
vendors = []
for i in range(15):
vendor = Vendor(
vendor_code=f"PAGEVENDOR{i:03d}_{unique_suffix}",
@@ -202,9 +240,7 @@ class TestPagination:
db.commit()
# Test first page (assuming admin endpoint exists)
response = client.get(
"/api/v1/vendor?limit=5&skip=0", headers=admin_headers
)
response = client.get("/api/v1/vendor?limit=5&skip=0", headers=admin_headers)
assert response.status_code == 200
data = response.json()
assert len(data["vendors"]) == 5
@@ -215,10 +251,12 @@ class TestPagination:
def test_inventory_pagination_success(self, client, auth_headers, db):
"""Test pagination for inventory listing successfully"""
import uuid
unique_suffix = str(uuid.uuid4())[:8]
# Create multiple inventory entries
from models.database.inventory import Inventory
inventory_entries = []
for i in range(20):
inventory = Inventory(
@@ -249,7 +287,9 @@ class TestPagination:
import time
start_time = time.time()
response = client.get("/api/v1/marketplace/product?skip=1000&limit=10", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?skip=1000&limit=10", headers=auth_headers
)
end_time = time.time()
assert response.status_code == 200
@@ -262,19 +302,25 @@ class TestPagination:
def test_pagination_with_invalid_parameters_types(self, client, auth_headers):
"""Test pagination with invalid parameter types returns ValidationException"""
# Test non-numeric skip
response = client.get("/api/v1/marketplace/product?skip=invalid", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?skip=invalid", headers=auth_headers
)
assert response.status_code == 422
data = response.json()
assert data["error_code"] == "VALIDATION_ERROR"
# Test non-numeric limit
response = client.get("/api/v1/marketplace/product?limit=invalid", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?limit=invalid", headers=auth_headers
)
assert response.status_code == 422
data = response.json()
assert data["error_code"] == "VALIDATION_ERROR"
# Test float values (should be converted or rejected)
response = client.get("/api/v1/marketplace/product?skip=10.5&limit=5.5", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?skip=10.5&limit=5.5", headers=auth_headers
)
assert response.status_code in [200, 422] # Depends on implementation
def test_empty_dataset_pagination(self, client, auth_headers):
@@ -282,7 +328,7 @@ class TestPagination:
# Use a filter that should return no results
response = client.get(
"/api/v1/marketplace/product?brand=NonexistentBrand999&limit=10&skip=0",
headers=auth_headers
headers=auth_headers,
)
assert response.status_code == 200
@@ -294,7 +340,9 @@ class TestPagination:
def test_exception_structure_in_pagination_errors(self, client, auth_headers):
"""Test that pagination validation errors follow consistent exception structure"""
response = client.get("/api/v1/marketplace/product?skip=-1", headers=auth_headers)
response = client.get(
"/api/v1/marketplace/product?skip=-1", headers=auth_headers
)
assert response.status_code == 422
data = response.json()