import pytest from app.schemas.Catalog import ProductCreate, VariantAttributeResponse def test_product_create_schema_long_description(): long_desc = "

" + ("Feature detail content. " * 300) + "

" payload = { "category_id": "01HXXXXXXX0000000000000000", "name": "iPhone 12 Display", "description": long_desc, "seo_description": "Clean SEO snippet description."[:500], "variants": [ { "sku": "IP12-DISP-001", "price": 4999.00, "cost_price": 3000.00, "low_stock_threshold": 5, "status": "active", "attributes": [] } ] } product = ProductCreate(**payload) assert product.name == "iPhone 12 Display" assert len(product.description) > 4000 assert len(product.seo_description) <= 500 def test_product_create_schema_seo_description_capped(): seo_desc = "A" * 500 payload = { "category_id": "01HXXXXXXX0000000000000000", "name": "iPhone 12 Display", "seo_description": seo_desc, "variants": [ { "sku": "IP12-DISP-002", "price": 4999.00, "cost_price": 3000.00, "low_stock_threshold": 5, "status": "active", "attributes": [] } ] } product = ProductCreate(**payload) assert len(product.seo_description) == 500 def test_variant_attribute_resolution_qul_to_quality(): attr_dict = { "id": "01HXXXXXXX0000000000000001", "variant_id": "01HXXXXXXX0000000000000002", "attribute_id": "01HXXXXXXX0000000000000003", "attribute_value": "INCELL", "attribute_name": "QUL", "attribute_code": "qul" } resp = VariantAttributeResponse(**attr_dict) assert resp.attribute_name == "Quality" assert resp.attribute_code == "qul"