This commit is contained in:
2025-09-21 13:00:10 +02:00
parent a26f8086f8
commit c2a1056db7
56 changed files with 339 additions and 104 deletions

View File

@@ -1,3 +1,2 @@
# tests/unit/__init__.py
"""Unit tests - fast, isolated component tests."""

View File

@@ -3,4 +3,3 @@
import pytest
# Add any unit-specific fixtures here if needed

View File

@@ -6,6 +6,7 @@ import pytest
from middleware.auth import AuthManager
from middleware.rate_limiter import RateLimiter
@pytest.mark.unit
@pytest.mark.auth # for auth manager tests
class TestRateLimiter:

View File

@@ -1,3 +1,2 @@
# tests/unit/models/__init__.py
"""Database and API model unit tests."""

View File

@@ -1,3 +1,2 @@
# tests/unit/services/__init__.py
"""Service layer unit tests."""

View File

@@ -114,4 +114,4 @@ class TestAdminService:
assert test_job is not None
assert test_job.marketplace == test_marketplace_job.marketplace
assert test_job.shop_name == test_marketplace_job.shop_name
assert test_job.status == test_marketplace_job.status
assert test_job.status == test_marketplace_job.status

View File

@@ -6,6 +6,7 @@ from app.services.auth_service import AuthService
from models.api.auth import UserLogin, UserRegister
from models.database.user import User
@pytest.mark.unit
@pytest.mark.auth
class TestAuthService:

View File

@@ -10,6 +10,7 @@ from models.database.marketplace import MarketplaceImportJob
from models.database.shop import Shop
from models.database.user import User
@pytest.mark.unit
@pytest.mark.marketplace
class TestMarketplaceService:

View File

@@ -5,6 +5,7 @@ from app.services.product_service import ProductService
from models.api.product import ProductCreate
from models.database.product import Product
@pytest.mark.unit
@pytest.mark.products
class TestProductService:

View File

@@ -5,6 +5,7 @@ from fastapi import HTTPException
from app.services.shop_service import ShopService
from models.api.shop import ShopCreate, ShopProductCreate
@pytest.mark.unit
@pytest.mark.shops
class TestShopService:

View File

@@ -5,6 +5,7 @@ from app.services.stats_service import StatsService
from models.database.product import Product
from models.database.stock import Stock
@pytest.mark.unit
@pytest.mark.stats
class TestStatsService:

View File

@@ -8,6 +8,7 @@ from models.api.stock import StockAdd, StockCreate, StockUpdate
from models.database.product import Product
from models.database.stock import Stock
@pytest.mark.unit
@pytest.mark.stock
class TestStockService:

View File

@@ -1,3 +1,2 @@
# tests/unit/utils/__init__.py
"""Utility function unit tests."""

View File

@@ -8,6 +8,7 @@ import requests.exceptions
from utils.csv_processor import CSVProcessor
@pytest.mark.unit
class TestCSVProcessor:
def setup_method(self):
@@ -80,7 +81,9 @@ class TestCSVProcessor:
# Mock failed HTTP response - need to make raise_for_status() raise an exception
mock_response = Mock()
mock_response.status_code = 404
mock_response.raise_for_status.side_effect = requests.exceptions.HTTPError("404 Not Found")
mock_response.raise_for_status.side_effect = requests.exceptions.HTTPError(
"404 Not Found"
)
mock_get.return_value = mock_response
with pytest.raises(requests.exceptions.HTTPError):

View File

@@ -3,6 +3,7 @@ import pytest
from utils.data_processing import GTINProcessor, PriceProcessor
@pytest.mark.unit
class TestDataValidation:
def test_gtin_normalization_edge_cases(self):