fix: add required address fields to order service tests

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 <noreply@anthropic.com>
This commit is contained in:
2025-12-28 17:45:09 +01:00
parent e21630d63a
commit 3c403ab1b8

View File

@@ -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()