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>
This commit is contained in:
@@ -3,18 +3,44 @@
|
||||
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 vendor_with_subdomain(db):
|
||||
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(
|
||||
name="Test Vendor", code="testvendor", subdomain="testvendor", is_active=True
|
||||
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()
|
||||
@@ -23,13 +49,16 @@ def vendor_with_subdomain(db):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def vendor_with_custom_domain(db):
|
||||
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",
|
||||
code="customvendor",
|
||||
vendor_code=f"CUSTOMVENDOR_{unique_id.upper()}",
|
||||
subdomain="customvendor",
|
||||
is_active=True,
|
||||
is_verified=True,
|
||||
)
|
||||
db.add(vendor)
|
||||
db.commit()
|
||||
@@ -46,13 +75,16 @@ def vendor_with_custom_domain(db):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def vendor_with_theme(db):
|
||||
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",
|
||||
code="themedvendor",
|
||||
vendor_code=f"THEMEDVENDOR_{unique_id.upper()}",
|
||||
subdomain="themedvendor",
|
||||
is_active=True,
|
||||
is_verified=True,
|
||||
)
|
||||
db.add(vendor)
|
||||
db.commit()
|
||||
@@ -74,10 +106,16 @@ def vendor_with_theme(db):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inactive_vendor(db):
|
||||
def middleware_inactive_vendor(db, middleware_test_company):
|
||||
"""Create an inactive vendor for testing."""
|
||||
unique_id = str(uuid.uuid4())[:8]
|
||||
vendor = Vendor(
|
||||
name="Inactive Vendor", code="inactive", subdomain="inactive", is_active=False
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user