fix: correct tojson|safe usage in templates and update validator
- Remove |safe from |tojson in HTML attributes (x-data) - quotes must become " for browsers to parse correctly - Update LANG-002 and LANG-003 architecture rules to document correct |tojson usage patterns: - HTML attributes: |tojson (no |safe) - Script blocks: |tojson|safe - Fix validator to warn when |tojson|safe is used in x-data (breaks HTML attribute parsing) - Improve code quality across services, APIs, and tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# tests/unit/models/schema/test_auth.py
|
||||
"""Unit tests for auth Pydantic schemas."""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
# tests/unit/models/schema/test_customer.py
|
||||
"""Unit tests for customer Pydantic schemas."""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from models.schema.customer import (
|
||||
CustomerRegister,
|
||||
CustomerUpdate,
|
||||
CustomerResponse,
|
||||
CustomerAddressCreate,
|
||||
CustomerAddressUpdate,
|
||||
CustomerAddressResponse,
|
||||
CustomerAddressUpdate,
|
||||
CustomerPreferencesUpdate,
|
||||
CustomerRegister,
|
||||
CustomerResponse,
|
||||
CustomerUpdate,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# tests/unit/models/schema/test_inventory.py
|
||||
"""Unit tests for inventory Pydantic schemas."""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from models.schema.inventory import (
|
||||
InventoryBase,
|
||||
InventoryCreate,
|
||||
InventoryAdjust,
|
||||
InventoryUpdate,
|
||||
InventoryCreate,
|
||||
InventoryLocationResponse,
|
||||
InventoryReserve,
|
||||
InventoryResponse,
|
||||
InventoryLocationResponse,
|
||||
InventoryUpdate,
|
||||
ProductInventorySummary,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
# tests/unit/models/schema/test_marketplace_import_job.py
|
||||
"""Unit tests for marketplace import job Pydantic schemas."""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from models.schema.marketplace_import_job import (
|
||||
MarketplaceImportJobListResponse,
|
||||
MarketplaceImportJobRequest,
|
||||
MarketplaceImportJobResponse,
|
||||
MarketplaceImportJobListResponse,
|
||||
MarketplaceImportJobStatusUpdate,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
# tests/unit/models/schema/test_order.py
|
||||
"""Unit tests for order Pydantic schemas."""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from models.schema.order import (
|
||||
OrderAddressCreate,
|
||||
OrderCreate,
|
||||
OrderItemCreate,
|
||||
OrderItemResponse,
|
||||
OrderAddressCreate,
|
||||
OrderAddressResponse,
|
||||
OrderCreate,
|
||||
OrderUpdate,
|
||||
OrderResponse,
|
||||
OrderDetailResponse,
|
||||
OrderListResponse,
|
||||
OrderResponse,
|
||||
OrderUpdate,
|
||||
)
|
||||
|
||||
|
||||
@@ -253,7 +252,14 @@ class TestOrderUpdateSchema:
|
||||
|
||||
def test_valid_status_values(self):
|
||||
"""Test all valid status values."""
|
||||
valid_statuses = ["pending", "processing", "shipped", "delivered", "cancelled", "refunded"]
|
||||
valid_statuses = [
|
||||
"pending",
|
||||
"processing",
|
||||
"shipped",
|
||||
"delivered",
|
||||
"cancelled",
|
||||
"refunded",
|
||||
]
|
||||
for status in valid_statuses:
|
||||
update = OrderUpdate(status=status)
|
||||
assert update.status == status
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# tests/unit/models/schema/test_product.py
|
||||
"""Unit tests for product Pydantic schemas."""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from models.schema.product import (
|
||||
ProductCreate,
|
||||
ProductUpdate,
|
||||
ProductResponse,
|
||||
ProductDetailResponse,
|
||||
ProductListResponse,
|
||||
ProductResponse,
|
||||
ProductUpdate,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
# tests/unit/models/schema/test_vendor.py
|
||||
"""Unit tests for vendor Pydantic schemas."""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from models.schema.vendor import (
|
||||
VendorCreate,
|
||||
VendorUpdate,
|
||||
VendorResponse,
|
||||
VendorDetailResponse,
|
||||
VendorListResponse,
|
||||
VendorResponse,
|
||||
VendorSummary,
|
||||
VendorUpdate,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user