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/database/test_product.py
|
||||
"""Unit tests for Product (vendor catalog) database model."""
|
||||
|
||||
import pytest
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
@@ -35,10 +36,9 @@ class TestProductModel:
|
||||
assert product.is_featured is True
|
||||
assert product.vendor.vendor_code == test_vendor.vendor_code
|
||||
# Use get_title() method instead of .title attribute
|
||||
assert (
|
||||
product.marketplace_product.get_title("en")
|
||||
== test_marketplace_product.get_title("en")
|
||||
)
|
||||
assert product.marketplace_product.get_title(
|
||||
"en"
|
||||
) == test_marketplace_product.get_title("en")
|
||||
|
||||
def test_product_unique_per_vendor(self, db, test_vendor, test_marketplace_product):
|
||||
"""Test that same marketplace product can't be added twice to vendor catalog."""
|
||||
@@ -75,7 +75,9 @@ class TestProductModel:
|
||||
assert product.min_quantity == 1 # Default
|
||||
assert product.display_order == 0 # Default
|
||||
|
||||
def test_product_vendor_override_fields(self, db, test_vendor, test_marketplace_product):
|
||||
def test_product_vendor_override_fields(
|
||||
self, db, test_vendor, test_marketplace_product
|
||||
):
|
||||
"""Test Product model vendor-specific override fields."""
|
||||
product = Product(
|
||||
vendor_id=test_vendor.id,
|
||||
@@ -97,7 +99,9 @@ class TestProductModel:
|
||||
assert product.currency == "USD"
|
||||
assert product.availability == "limited"
|
||||
|
||||
def test_product_inventory_settings(self, db, test_vendor, test_marketplace_product):
|
||||
def test_product_inventory_settings(
|
||||
self, db, test_vendor, test_marketplace_product
|
||||
):
|
||||
"""Test Product model inventory settings."""
|
||||
product = Product(
|
||||
vendor_id=test_vendor.id,
|
||||
@@ -126,7 +130,9 @@ class TestProductModel:
|
||||
assert product.marketplace_product is not None
|
||||
assert product.inventory_entries == [] # No inventory yet
|
||||
|
||||
def test_product_effective_properties(self, db, test_vendor, test_marketplace_product):
|
||||
def test_product_effective_properties(
|
||||
self, db, test_vendor, test_marketplace_product
|
||||
):
|
||||
"""Test Product effective properties with override pattern."""
|
||||
# First, set some values on the marketplace product
|
||||
test_marketplace_product.price_numeric = 100.00
|
||||
|
||||
Reference in New Issue
Block a user