fix: backend improvements (customer health, tests, middleware, corpus)
This commit is contained in:
@@ -214,8 +214,11 @@ class TestProductAPI:
|
||||
response = await client.delete(f"/api/v1/products/{pid}", headers=auth_headers)
|
||||
assert response.status_code == 200
|
||||
|
||||
# Product is soft-deleted (is_active=False), still retrievable
|
||||
response = await client.get(f"/api/v1/products/{pid}", headers=auth_headers)
|
||||
assert response.status_code == 404
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["is_active"] is False
|
||||
|
||||
|
||||
class TestQuotationAPI:
|
||||
@@ -299,15 +302,20 @@ class TestOnboardingAPI:
|
||||
response = await client.get("/api/v1/onboarding/status", headers=auth_headers)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "completed" in data
|
||||
assert "product_count" in data
|
||||
assert "onboarded" in data
|
||||
assert data["onboarded"] is False
|
||||
|
||||
async def test_onboarding_create_product(self, client: AsyncClient, auth_headers):
|
||||
with patch("app.services.onboarding.OnboardingService.create_product") as mock:
|
||||
with patch("app.services.onboarding.OnboardingService.generate_first_product") as mock:
|
||||
mock.return_value = {
|
||||
"id": "mock-id",
|
||||
"name": "Onboarded Product",
|
||||
"marketing_contents": [],
|
||||
"product": {
|
||||
"id": "mock-id",
|
||||
"name": "Onboarded Product",
|
||||
"description": "Desc",
|
||||
"category": "tools",
|
||||
"keywords": [],
|
||||
},
|
||||
"generated_content": [],
|
||||
"keywords": [],
|
||||
}
|
||||
response = await client.post(
|
||||
@@ -321,17 +329,17 @@ class TestOnboardingAPI:
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["name"] == "Onboarded Product"
|
||||
assert response.json()["product"]["name"] == "Onboarded Product"
|
||||
|
||||
|
||||
class TestExportAPI:
|
||||
async def test_export_customers_csv(self, client: AsyncClient, auth_headers):
|
||||
response = await client.get("/api/v1/customers/export/csv", headers=auth_headers)
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"] == "text/csv"
|
||||
assert "text/csv" in response.headers["content-type"]
|
||||
assert "customers.csv" in response.headers["content-disposition"]
|
||||
|
||||
async def test_export_quotations_csv(self, client: AsyncClient, auth_headers):
|
||||
response = await client.get("/api/v1/quotations/export/csv", headers=auth_headers)
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"] == "text/csv"
|
||||
assert "text/csv" in response.headers["content-type"]
|
||||
|
||||
Reference in New Issue
Block a user