From 3c403ab1b89c9c46cb3c121c2c712ce5ad4a4164 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sun, 28 Dec 2025 17:45:09 +0100 Subject: [PATCH] fix: add required address fields to order service tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added billing and shipping address fields to Order test fixtures to fix NOT NULL constraint errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- tests/unit/services/test_order_service.py | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit/services/test_order_service.py b/tests/unit/services/test_order_service.py index 470a16f1..781287dc 100644 --- a/tests/unit/services/test_order_service.py +++ b/tests/unit/services/test_order_service.py @@ -31,6 +31,25 @@ from models.database.customer import Customer from models.database.order import Order, OrderItem +# Default address fields required by Order model +DEFAULT_ADDRESS = { + # Shipping address + "ship_first_name": "Test", + "ship_last_name": "Customer", + "ship_address_line_1": "123 Test St", + "ship_city": "Test City", + "ship_postal_code": "12345", + "ship_country_iso": "LU", + # Billing address + "bill_first_name": "Test", + "bill_last_name": "Customer", + "bill_address_line_1": "123 Test St", + "bill_city": "Test City", + "bill_postal_code": "12345", + "bill_country_iso": "LU", +} + + @pytest.mark.unit @pytest.mark.service class TestOrderServiceNumberGeneration: @@ -149,6 +168,7 @@ class TestOrderServiceRetrieval: customer_last_name="Customer", customer_email="test@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) db.add(order) db.commit() @@ -181,6 +201,7 @@ class TestOrderServiceRetrieval: customer_last_name="Test", customer_email="filter@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) order2 = Order( vendor_id=test_vendor.id, @@ -194,6 +215,7 @@ class TestOrderServiceRetrieval: customer_last_name="Test", customer_email="another@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) db.add(order1) db.add(order2) @@ -234,6 +256,7 @@ class TestOrderServiceRetrieval: customer_last_name="Customer", customer_email="test@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) db.add(order) db.commit() @@ -285,6 +308,7 @@ class TestOrderServiceStats: customer_last_name="Customer", customer_email="test@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) db.add(order) db.commit() @@ -318,6 +342,7 @@ class TestOrderServiceUpdates: customer_last_name="Customer", customer_email="test@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) db.add(order) db.commit() @@ -346,6 +371,7 @@ class TestOrderServiceUpdates: customer_last_name="Customer", customer_email="test@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) db.add(order) db.commit() @@ -417,6 +443,7 @@ class TestOrderServiceAdmin: customer_last_name="Customer", customer_email="test@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) db.add(order) db.commit() @@ -524,6 +551,7 @@ class TestOrderServiceLetzshop: customer_last_name="Customer", customer_email="test@example.com", order_date=datetime.now(UTC), + **DEFAULT_ADDRESS, ) db.add(existing) db.commit()