Application fully migrated to modular approach
This commit is contained in:
@@ -4,10 +4,8 @@ from unittest.mock import patch, AsyncMock
|
||||
|
||||
|
||||
class TestMarketplaceAPI:
|
||||
@patch('utils.csv_processor.CSVProcessor.process_marketplace_csv_from_url')
|
||||
def test_import_from_marketplace(self, mock_process, client, auth_headers, test_shop):
|
||||
"""Test marketplace import endpoint"""
|
||||
mock_process.return_value = AsyncMock()
|
||||
def test_import_from_marketplace(self, client, auth_headers, test_shop):
|
||||
"""Test marketplace import endpoint - just test job creation"""
|
||||
|
||||
import_data = {
|
||||
"url": "https://example.com/products.csv",
|
||||
@@ -15,7 +13,7 @@ class TestMarketplaceAPI:
|
||||
"shop_code": test_shop.shop_code
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/marketplace/import-from-marketplace",
|
||||
response = client.post("/api/v1/marketplace/import-product",
|
||||
headers=auth_headers, json=import_data)
|
||||
|
||||
assert response.status_code == 200
|
||||
@@ -24,6 +22,8 @@ class TestMarketplaceAPI:
|
||||
assert data["marketplace"] == "TestMarket"
|
||||
assert "job_id" in data
|
||||
|
||||
# Don't test the background task here - test it separately
|
||||
|
||||
def test_import_from_marketplace_invalid_shop(self, client, auth_headers):
|
||||
"""Test marketplace import with invalid shop"""
|
||||
import_data = {
|
||||
@@ -32,7 +32,7 @@ class TestMarketplaceAPI:
|
||||
"shop_code": "NONEXISTENT"
|
||||
}
|
||||
|
||||
response = client.post("/api/v1/marketplace/import-from-marketplace",
|
||||
response = client.post("/api/v1/marketplace/import-product",
|
||||
headers=auth_headers, json=import_data)
|
||||
|
||||
assert response.status_code == 404
|
||||
@@ -40,13 +40,13 @@ class TestMarketplaceAPI:
|
||||
|
||||
def test_get_marketplace_import_jobs(self, client, auth_headers):
|
||||
"""Test getting marketplace import jobs"""
|
||||
response = client.get("/api/v1/marketplace/marketplace-import-jobs", headers=auth_headers)
|
||||
response = client.get("/api/v1/marketplace/import-jobs", headers=auth_headers)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert isinstance(response.json(), list)
|
||||
|
||||
def test_marketplace_requires_auth(self, client):
|
||||
def test_get_marketplace_without_auth(self, client):
|
||||
"""Test that marketplace endpoints require authentication"""
|
||||
response = client.get("/api/v1/marketplace/marketplace-import-jobs")
|
||||
assert response.status_code == 403
|
||||
response = client.get("/api/v1/marketplace/import-jobs")
|
||||
assert response.status_code == 401 # No authorization header
|
||||
|
||||
|
||||
Reference in New Issue
Block a user