fix: update letzshop API to use unified Order model properties

- Change message exceptions (MessageAttachmentException,
  InvalidConversationTypeException, InvalidRecipientTypeException)
  to extend BusinessLogicException instead of ValidationException
  which doesn't accept error_code parameter

- Update vendor letzshop API endpoints:
  - Change sync_status query param to status in list_orders()
  - Fix response mapping to use unified Order model properties
    (external_order_id, external_shipment_id, status, etc.)
  - Fix confirm_order() to get inventory unit IDs from order items
  - Fix set_tracking() to use external_shipment_id

- Add order_date to test fixtures (required NOT NULL field)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-22 23:13:00 +01:00
parent 6f8434f200
commit feca2e19fe
4 changed files with 86 additions and 45 deletions

View File

@@ -246,6 +246,8 @@ class TestAdminLetzshopOrdersAPI:
def test_list_vendor_orders_with_data(self, client, db, admin_headers, test_vendor):
"""Test listing vendor orders with data."""
from datetime import datetime, timezone
from models.database.order import Order
# Create test order using unified Order model with all required fields
@@ -256,6 +258,7 @@ class TestAdminLetzshopOrdersAPI:
channel="letzshop",
external_order_id="admin_order_1",
status="pending",
order_date=datetime.now(timezone.utc),
customer_first_name="Admin",
customer_last_name="Test",
customer_email="admin-test@example.com",

View File

@@ -238,6 +238,8 @@ class TestVendorLetzshopOrdersAPI:
self, client, db, vendor_user_headers, test_vendor_with_vendor_user
):
"""Test listing orders with status filter."""
from datetime import datetime, timezone
from models.database.order import Order
# Create test orders using unified Order model with all required fields
@@ -248,6 +250,7 @@ class TestVendorLetzshopOrdersAPI:
channel="letzshop",
external_order_id="order_1",
status="pending",
order_date=datetime.now(timezone.utc),
customer_first_name="Test",
customer_last_name="User",
customer_email="test1@example.com",
@@ -273,6 +276,7 @@ class TestVendorLetzshopOrdersAPI:
channel="letzshop",
external_order_id="order_2",
status="processing",
order_date=datetime.now(timezone.utc),
customer_first_name="Test",
customer_last_name="User",
customer_email="test2@example.com",
@@ -309,6 +313,8 @@ class TestVendorLetzshopOrdersAPI:
self, client, db, vendor_user_headers, test_vendor_with_vendor_user
):
"""Test getting order detail."""
from datetime import datetime, timezone
from models.database.order import Order
order = Order(
@@ -319,6 +325,7 @@ class TestVendorLetzshopOrdersAPI:
external_order_id="order_detail_test",
external_shipment_id="shipment_1",
status="pending",
order_date=datetime.now(timezone.utc),
customer_first_name="Test",
customer_last_name="User",
customer_email="test@example.com",
@@ -448,6 +455,8 @@ class TestVendorLetzshopFulfillmentAPI:
test_vendor_with_vendor_user,
):
"""Test confirming an order."""
from datetime import datetime, timezone
from models.database.order import Order, OrderItem
# Create test order using unified Order model with all required fields
@@ -459,6 +468,7 @@ class TestVendorLetzshopFulfillmentAPI:
external_order_id="order_confirm",
external_shipment_id="shipment_1",
status="pending",
order_date=datetime.now(timezone.utc),
customer_first_name="Test",
customer_last_name="User",
customer_email="test@example.com",
@@ -534,6 +544,8 @@ class TestVendorLetzshopFulfillmentAPI:
test_vendor_with_vendor_user,
):
"""Test setting tracking information."""
from datetime import datetime, timezone
from models.database.order import Order
order = Order(
@@ -544,6 +556,7 @@ class TestVendorLetzshopFulfillmentAPI:
external_order_id="order_tracking",
external_shipment_id="shipment_track",
status="processing", # confirmed state
order_date=datetime.now(timezone.utc),
customer_first_name="Test",
customer_last_name="User",
customer_email="test@example.com",