Files
orion/tests/integration/middleware/conftest.py
Samir Boulahtit 4cb4fec8e2 fix: update tests for current API structure and model changes
- Fix middleware fixtures: vendor_code instead of code, add owner_user_id to company
- Fix performance tests: MarketplaceProduct uses translations for title/description
- Fix security tests: use correct API endpoints (/api/v1/admin/*, /api/v1/vendor/*)
- Fix workflow tests: use actual admin API endpoints
- Fix background task tests: remove invalid vendor_name field, add language

Note: Many middleware integration tests still fail due to dynamic routes
being caught by the /{slug} catch-all route. These tests need further
refactoring to use /api/* prefixed routes.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 16:01:16 +01:00

124 lines
3.2 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,
primary_color="#FF5733",
secondary_color="#33FF57",
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