Deployment Script, Postgres migration, UX improvements
This commit is contained in:
@@ -344,6 +344,41 @@ def test_mix_calculator_endpoints_respect_owner_visibility():
|
||||
assert operator_detail_response.status_code == 404
|
||||
|
||||
|
||||
def test_mix_calculator_pdf_endpoint_returns_pdf():
|
||||
with TestClient(app) as client:
|
||||
superadmin_login = client.post(
|
||||
"/api/auth/client/login",
|
||||
json={"email": settings.client_email, "password": settings.client_password},
|
||||
)
|
||||
headers = {"Authorization": f"Bearer {superadmin_login.json()['token']}"}
|
||||
|
||||
options_response = client.get("/api/mix-calculator/options", headers=headers)
|
||||
seeded_product = next(
|
||||
product for product in options_response.json()["products"] if product["product_name"] == "Specialty Pigeon Breeder 20kg"
|
||||
)
|
||||
|
||||
create_response = client.post(
|
||||
"/api/mix-calculator",
|
||||
json={
|
||||
"mix_date": "2026-04-29",
|
||||
"client_name": seeded_product["client_name"],
|
||||
"product_id": seeded_product["product_id"],
|
||||
"batch_size_kg": 560,
|
||||
"prepared_by_name": "Amelia Hart",
|
||||
"notes": "Morning production run",
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
created = create_response.json()
|
||||
|
||||
pdf_response = client.get(f"/api/mix-calculator/{created['id']}/pdf", headers=headers)
|
||||
|
||||
assert pdf_response.status_code == 200
|
||||
assert pdf_response.headers["content-type"] == "application/pdf"
|
||||
assert "attachment;" in pdf_response.headers["content-disposition"]
|
||||
assert pdf_response.content.startswith(b"%PDF")
|
||||
|
||||
|
||||
def test_module_permission_blocks_client_module_access():
|
||||
with TestClient(app) as client:
|
||||
admin_login_response = client.post(
|
||||
|
||||
Reference in New Issue
Block a user