- Update VendorTheme fixture to use new colors dict structure - Update theme tests to check colors dict instead of individual fields - Update CustomerPreferencesUpdate test for preferred_language field 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
131 lines
3.4 KiB
Python
131 lines
3.4 KiB
Python
# tests/integration/middleware/conftest.py
|
|
"""
|
|
Fixtures specific to middleware integration tests.
|
|
"""
|
|
|
|
import uuid
|
|
|
|
import pytest
|
|
|
|
from models.database.company import Company
|
|
from models.database.vendor import Vendor
|
|
from models.database.vendor_domain import VendorDomain
|
|
from models.database.vendor_theme import VendorTheme
|
|
|
|
|
|
@pytest.fixture
|
|
def middleware_test_company(db, test_user):
|
|
"""Create a company for middleware test vendors."""
|
|
unique_id = str(uuid.uuid4())[:8]
|
|
company = Company(
|
|
name=f"Middleware Test Company {unique_id}",
|
|
contact_email=f"middleware{unique_id}@test.com",
|
|
owner_user_id=test_user.id,
|
|
is_active=True,
|
|
is_verified=True,
|
|
)
|
|
db.add(company)
|
|
db.commit()
|
|
db.refresh(company)
|
|
return company
|
|
|
|
|
|
@pytest.fixture
|
|
def vendor_with_subdomain(db, middleware_test_company):
|
|
"""Create a vendor with subdomain for testing."""
|
|
unique_id = str(uuid.uuid4())[:8]
|
|
vendor = Vendor(
|
|
company_id=middleware_test_company.id,
|
|
name="Test Vendor",
|
|
vendor_code=f"TESTVENDOR_{unique_id.upper()}",
|
|
subdomain="testvendor",
|
|
is_active=True,
|
|
is_verified=True,
|
|
)
|
|
db.add(vendor)
|
|
db.commit()
|
|
db.refresh(vendor)
|
|
return vendor
|
|
|
|
|
|
@pytest.fixture
|
|
def vendor_with_custom_domain(db, middleware_test_company):
|
|
"""Create a vendor with custom domain for testing."""
|
|
unique_id = str(uuid.uuid4())[:8]
|
|
vendor = Vendor(
|
|
company_id=middleware_test_company.id,
|
|
name="Custom Domain Vendor",
|
|
vendor_code=f"CUSTOMVENDOR_{unique_id.upper()}",
|
|
subdomain="customvendor",
|
|
is_active=True,
|
|
is_verified=True,
|
|
)
|
|
db.add(vendor)
|
|
db.commit()
|
|
db.refresh(vendor)
|
|
|
|
# Add custom domain
|
|
domain = VendorDomain(
|
|
vendor_id=vendor.id, domain="customdomain.com", is_active=True, is_primary=True
|
|
)
|
|
db.add(domain)
|
|
db.commit()
|
|
|
|
return vendor
|
|
|
|
|
|
@pytest.fixture
|
|
def vendor_with_theme(db, middleware_test_company):
|
|
"""Create a vendor with custom theme for testing."""
|
|
unique_id = str(uuid.uuid4())[:8]
|
|
vendor = Vendor(
|
|
company_id=middleware_test_company.id,
|
|
name="Themed Vendor",
|
|
vendor_code=f"THEMEDVENDOR_{unique_id.upper()}",
|
|
subdomain="themedvendor",
|
|
is_active=True,
|
|
is_verified=True,
|
|
)
|
|
db.add(vendor)
|
|
db.commit()
|
|
db.refresh(vendor)
|
|
|
|
# Add custom theme
|
|
theme = VendorTheme(
|
|
vendor_id=vendor.id,
|
|
theme_name="custom",
|
|
colors={
|
|
"primary": "#FF5733",
|
|
"secondary": "#33FF57",
|
|
"accent": "#ec4899",
|
|
"background": "#ffffff",
|
|
"text": "#1f2937",
|
|
"border": "#e5e7eb",
|
|
},
|
|
logo_url="/static/vendors/themedvendor/logo.png",
|
|
favicon_url="/static/vendors/themedvendor/favicon.ico",
|
|
custom_css="body { background: #FF5733; }",
|
|
)
|
|
db.add(theme)
|
|
db.commit()
|
|
|
|
return vendor
|
|
|
|
|
|
@pytest.fixture
|
|
def middleware_inactive_vendor(db, middleware_test_company):
|
|
"""Create an inactive vendor for testing."""
|
|
unique_id = str(uuid.uuid4())[:8]
|
|
vendor = Vendor(
|
|
company_id=middleware_test_company.id,
|
|
name="Inactive Vendor",
|
|
vendor_code=f"INACTIVE_{unique_id.upper()}",
|
|
subdomain="inactive",
|
|
is_active=False,
|
|
is_verified=False,
|
|
)
|
|
db.add(vendor)
|
|
db.commit()
|
|
db.refresh(vendor)
|
|
return vendor
|