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

@@ -23,7 +23,9 @@ class TestVendorsAPI:
assert data["name"] == "New Vendor"
assert data["is_active"] is True
def test_create_vendor_duplicate_code_returns_conflict(self, client, auth_headers, test_vendor):
def test_create_vendor_duplicate_code_returns_conflict(
self, client, auth_headers, test_vendor
):
"""Test creating vendor with duplicate code returns VendorAlreadyExistsException"""
vendor_data = {
"vendor_code": test_vendor.vendor_code,
@@ -40,7 +42,9 @@ class TestVendorsAPI:
assert test_vendor.vendor_code in data["message"]
assert data["details"]["vendor_code"] == test_vendor.vendor_code
def test_create_vendor_missing_vendor_code_validation_error(self, client, auth_headers):
def test_create_vendor_missing_vendor_code_validation_error(
self, client, auth_headers
):
"""Test creating vendor without vendor_code returns ValidationException"""
vendor_data = {
"name": "Vendor without Code",
@@ -56,7 +60,9 @@ class TestVendorsAPI:
assert "Request validation failed" in data["message"]
assert "validation_errors" in data["details"]
def test_create_vendor_empty_vendor_name_validation_error(self, client, auth_headers):
def test_create_vendor_empty_vendor_name_validation_error(
self, client, auth_headers
):
"""Test creating vendor with empty name returns VendorValidationException"""
vendor_data = {
"vendor_code": "EMPTYNAME",
@@ -73,7 +79,9 @@ class TestVendorsAPI:
assert "Vendor name is required" in data["message"]
assert data["details"]["field"] == "name"
def test_create_vendor_max_vendors_reached_business_logic_error(self, client, auth_headers, db, test_user):
def test_create_vendor_max_vendors_reached_business_logic_error(
self, client, auth_headers, db, test_user
):
"""Test creating vendor when max vendors reached returns MaxVendorsReachedException"""
# This test would require creating the maximum allowed vendors first
# The exact implementation depends on your business rules
@@ -94,8 +102,10 @@ class TestVendorsAPI:
assert data["total"] >= 1
assert len(data["vendors"]) >= 1
# Find our test vendor
test_vendor_found = any(s["vendor_code"] == test_vendor.vendor_code for s in data["vendors"])
# Find our test vendor
test_vendor_found = any(
s["vendor_code"] == test_vendor.vendor_code for s in data["vendors"]
)
assert test_vendor_found
def test_get_vendors_with_filters(self, client, auth_headers, test_vendor):
@@ -105,7 +115,7 @@ class TestVendorsAPI:
assert response.status_code == 200
data = response.json()
for vendor in data["vendors"]:
assert vendor ["is_active"] is True
assert vendor["is_active"] is True
# Test verified_only filter
response = client.get("/api/v1/vendor?verified_only=true", headers=auth_headers)
@@ -135,7 +145,9 @@ class TestVendorsAPI:
assert data["details"]["resource_type"] == "Vendor"
assert data["details"]["identifier"] == "NONEXISTENT"
def test_get_vendor_unauthorized_access(self, client, auth_headers, test_vendor, other_user, db):
def test_get_vendor_unauthorized_access(
self, client, auth_headers, test_vendor, other_user, db
):
"""Test accessing vendor owned by another user returns UnauthorizedVendorAccessException"""
# Change vendor owner to other user AND make it unverified/inactive
# so that non-owner users cannot access it
@@ -154,7 +166,9 @@ class TestVendorsAPI:
assert test_vendor.vendor_code in data["message"]
assert data["details"]["vendor_code"] == test_vendor.vendor_code
def test_get_vendor_unauthorized_access_with_inactive_vendor(self, client, auth_headers, inactive_vendor):
def test_get_vendor_unauthorized_access_with_inactive_vendor(
self, client, auth_headers, inactive_vendor
):
"""Test accessing inactive vendor owned by another user returns UnauthorizedVendorAccessException"""
# inactive_vendor fixture already creates an unverified, inactive vendor owned by other_user
response = client.get(
@@ -168,7 +182,9 @@ class TestVendorsAPI:
assert inactive_vendor.vendor_code in data["message"]
assert data["details"]["vendor_code"] == inactive_vendor.vendor_code
def test_get_vendor_public_access_allowed(self, client, auth_headers, verified_vendor):
def test_get_vendor_public_access_allowed(
self, client, auth_headers, verified_vendor
):
"""Test accessing verified vendor owned by another user is allowed (public access)"""
# verified_vendor fixture creates a verified, active vendor owned by other_user
# This should allow public access per your business logic
@@ -181,7 +197,9 @@ class TestVendorsAPI:
assert data["vendor_code"] == verified_vendor.vendor_code
assert data["name"] == verified_vendor.name
def test_add_product_to_vendor_success(self, client, auth_headers, test_vendor, unique_product):
def test_add_product_to_vendor_success(
self, client, auth_headers, test_vendor, unique_product
):
"""Test adding product to vendor successfully"""
product_data = {
"marketplace_product_id": unique_product.marketplace_product_id, # Use string marketplace_product_id, not database id
@@ -193,7 +211,7 @@ class TestVendorsAPI:
response = client.post(
f"/api/v1/vendor/{test_vendor.vendor_code}/products",
headers=auth_headers,
json=product_data
json=product_data,
)
assert response.status_code == 200
@@ -207,10 +225,15 @@ class TestVendorsAPI:
# MarketplaceProduct details are nested in the 'marketplace_product' field
assert "marketplace_product" in data
assert data["marketplace_product"]["marketplace_product_id"] == unique_product.marketplace_product_id
assert (
data["marketplace_product"]["marketplace_product_id"]
== unique_product.marketplace_product_id
)
assert data["marketplace_product"]["id"] == unique_product.id
def test_add_product_to_vendor_already_exists_conflict(self, client, auth_headers, test_vendor, test_product):
def test_add_product_to_vendor_already_exists_conflict(
self, client, auth_headers, test_vendor, test_product
):
"""Test adding product that already exists in vendor returns ProductAlreadyExistsException"""
# test_product fixture already creates a relationship, get the marketplace_product_id string
existing_product = test_product.marketplace_product
@@ -223,7 +246,7 @@ class TestVendorsAPI:
response = client.post(
f"/api/v1/vendor/{test_vendor.vendor_code}/products",
headers=auth_headers,
json=product_data
json=product_data,
)
assert response.status_code == 409
@@ -233,7 +256,9 @@ class TestVendorsAPI:
assert test_vendor.vendor_code in data["message"]
assert existing_product.marketplace_product_id in data["message"]
def test_add_nonexistent_product_to_vendor_not_found(self, client, auth_headers, test_vendor):
def test_add_nonexistent_product_to_vendor_not_found(
self, client, auth_headers, test_vendor
):
"""Test adding nonexistent product to vendor returns MarketplaceProductNotFoundException"""
product_data = {
"marketplace_product_id": "NONEXISTENT_PRODUCT", # Use string marketplace_product_id that doesn't exist
@@ -243,7 +268,7 @@ class TestVendorsAPI:
response = client.post(
f"/api/v1/vendor/{test_vendor.vendor_code}/products",
headers=auth_headers,
json=product_data
json=product_data,
)
assert response.status_code == 404
@@ -252,11 +277,12 @@ class TestVendorsAPI:
assert data["status_code"] == 404
assert "NONEXISTENT_PRODUCT" in data["message"]
def test_get_products_success(self, client, auth_headers, test_vendor, test_product):
def test_get_products_success(
self, client, auth_headers, test_vendor, test_product
):
"""Test getting vendor products successfully"""
response = client.get(
f"/api/v1/vendor/{test_vendor.vendor_code}/products",
headers=auth_headers
f"/api/v1/vendor/{test_vendor.vendor_code}/products", headers=auth_headers
)
assert response.status_code == 200
@@ -271,22 +297,21 @@ class TestVendorsAPI:
# Test active_only filter
response = client.get(
f"/api/v1/vendor/{test_vendor.vendor_code}/products?active_only=true",
headers=auth_headers
headers=auth_headers,
)
assert response.status_code == 200
# Test featured_only filter
response = client.get(
f"/api/v1/vendor/{test_vendor.vendor_code}/products?featured_only=true",
headers=auth_headers
headers=auth_headers,
)
assert response.status_code == 200
def test_get_products_from_nonexistent_vendor_not_found(self, client, auth_headers):
"""Test getting products from nonexistent vendor returns VendorNotFoundException"""
response = client.get(
"/api/v1/vendor/NONEXISTENT/products",
headers=auth_headers
"/api/v1/vendor/NONEXISTENT/products", headers=auth_headers
)
assert response.status_code == 404
@@ -295,7 +320,9 @@ class TestVendorsAPI:
assert data["status_code"] == 404
assert "NONEXISTENT" in data["message"]
def test_vendor_not_active_business_logic_error(self, client, auth_headers, test_vendor, db):
def test_vendor_not_active_business_logic_error(
self, client, auth_headers, test_vendor, db
):
"""Test accessing inactive vendor returns VendorNotActiveException (if enforced)"""
# Set vendor to inactive
test_vendor.is_active = False
@@ -313,7 +340,9 @@ class TestVendorsAPI:
assert data["status_code"] == 400
assert test_vendor.vendor_code in data["message"]
def test_vendor_not_verified_business_logic_error(self, client, auth_headers, test_vendor, db):
def test_vendor_not_verified_business_logic_error(
self, client, auth_headers, test_vendor, db
):
"""Test operations requiring verification returns VendorNotVerifiedException (if enforced)"""
# Set vendor to unverified
test_vendor.is_verified = False
@@ -328,7 +357,7 @@ class TestVendorsAPI:
response = client.post(
f"/api/v1/vendor/{test_vendor.vendor_code}/products",
headers=auth_headers,
json=product_data
json=product_data,
)
# If your service requires verification for adding products