marketplace refactoring

This commit is contained in:
2025-10-04 13:38:10 +02:00
parent 32be301d83
commit c971674ec2
68 changed files with 1102 additions and 1128 deletions

View File

@@ -18,7 +18,7 @@ class TestCSVProcessor:
def test_download_csv_encoding_fallback(self, mock_get):
"""Test CSV download with encoding fallback"""
# Create content with special characters that would fail UTF-8 if not properly encoded
special_content = "product_id,title,price\nTEST001,Café Product,10.99"
special_content = "marketplace_product_id,title,price\nTEST001,Café MarketplaceProduct,10.99"
mock_response = Mock()
mock_response.status_code = 200
@@ -31,7 +31,7 @@ class TestCSVProcessor:
mock_get.assert_called_once_with("http://example.com/test.csv", timeout=30)
assert isinstance(csv_content, str)
assert "Café Product" in csv_content
assert "Café MarketplaceProduct" in csv_content
@patch("requests.get")
def test_download_csv_encoding_ignore_fallback(self, mock_get):
@@ -41,7 +41,7 @@ class TestCSVProcessor:
mock_response.status_code = 200
# Create bytes that will fail most encodings
mock_response.content = (
b"product_id,title,price\nTEST001,\xff\xfe Product,10.99"
b"marketplace_product_id,title,price\nTEST001,\xff\xfe MarketplaceProduct,10.99"
)
mock_response.raise_for_status.return_value = None
mock_get.return_value = mock_response
@@ -51,7 +51,7 @@ class TestCSVProcessor:
mock_get.assert_called_once_with("http://example.com/test.csv", timeout=30)
assert isinstance(csv_content, str)
# Should still contain basic content even with ignored errors
assert "product_id,title,price" in csv_content
assert "marketplace_product_id,title,price" in csv_content
assert "TEST001" in csv_content
@patch("requests.get")
@@ -91,15 +91,15 @@ class TestCSVProcessor:
def test_parse_csv_content(self):
"""Test CSV content parsing"""
csv_content = """product_id,title,price,marketplace
TEST001,Test Product 1,10.99,TestMarket
TEST002,Test Product 2,15.99,TestMarket"""
csv_content = """marketplace_product_id,title,price,marketplace
TEST001,Test MarketplaceProduct 1,10.99,TestMarket
TEST002,Test MarketplaceProduct 2,15.99,TestMarket"""
df = self.processor.parse_csv(csv_content)
assert len(df) == 2
assert "product_id" in df.columns
assert df.iloc[0]["product_id"] == "TEST001"
assert "marketplace_product_id" in df.columns
assert df.iloc[0]["marketplace_product_id"] == "TEST001"
assert df.iloc[1]["price"] == 15.99
@pytest.mark.asyncio
@@ -112,8 +112,8 @@ TEST002,Test Product 2,15.99,TestMarket"""
mock_download.return_value = "csv_content"
mock_df = pd.DataFrame(
{
"product_id": ["TEST001", "TEST002"],
"title": ["Product 1", "Product 2"],
"marketplace_product_id": ["TEST001", "TEST002"],
"title": ["MarketplaceProduct 1", "MarketplaceProduct 2"],
"price": ["10.99", "15.99"],
"marketplace": ["TestMarket", "TestMarket"],
"shop_name": ["TestShop", "TestShop"],