Tests restructuring
This commit is contained in:
50
tests/fixtures/marketplace_fixtures.py
vendored
Normal file
50
tests/fixtures/marketplace_fixtures.py
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# tests/fixtures/marketplace_fixtures.py
|
||||
import pytest
|
||||
|
||||
from models.database_models import MarketplaceImportJob
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_marketplace_job(db, test_shop, test_user):
|
||||
"""Create a test marketplace import job"""
|
||||
job = MarketplaceImportJob(
|
||||
marketplace="amazon",
|
||||
shop_name="Test Import Shop",
|
||||
status="completed",
|
||||
source_url="https://test-marketplace.example.com/import",
|
||||
shop_id=test_shop.id,
|
||||
user_id=test_user.id,
|
||||
imported_count=5,
|
||||
updated_count=3,
|
||||
total_processed=8,
|
||||
error_count=0,
|
||||
error_message=None,
|
||||
)
|
||||
db.add(job)
|
||||
db.commit()
|
||||
db.refresh(job)
|
||||
return job
|
||||
|
||||
|
||||
def create_test_import_job(db, shop_id, user_id, **kwargs):
|
||||
"""Helper function to create MarketplaceImportJob with defaults"""
|
||||
defaults = {
|
||||
"marketplace": "test",
|
||||
"shop_name": "Test Shop",
|
||||
"status": "pending",
|
||||
"source_url": "https://test.example.com/import",
|
||||
"shop_id": shop_id,
|
||||
"user_id": user_id,
|
||||
"imported_count": 0,
|
||||
"updated_count": 0,
|
||||
"total_processed": 0,
|
||||
"error_count": 0,
|
||||
"error_message": None,
|
||||
}
|
||||
defaults.update(kwargs)
|
||||
|
||||
job = MarketplaceImportJob(**defaults)
|
||||
db.add(job)
|
||||
db.commit()
|
||||
db.refresh(job)
|
||||
return job
|
||||
Reference in New Issue
Block a user