Fixed Form Vlidation
This commit is contained in:
@@ -94,8 +94,10 @@ class TestFormApproval:
|
||||
state = _by_table(await client.get(f"{API}/approvals", headers=auth["mr1"]))["fare_chart"]
|
||||
assert state["status"] == "draft" and state["approved_by_name"] is None
|
||||
# A pending (not yet approved) form is withdrawn too, so the AM never signs stale data.
|
||||
# Deleting a row is admin-only — an MR can no longer delete their own rows.
|
||||
await client.post(f"{API}/fare_chart/approval/request", headers=auth["mr1"])
|
||||
assert (await client.delete(f"{API}/fare_chart/rows/{row_id}", headers=auth["mr1"])).status_code == 204
|
||||
assert (await client.delete(f"{API}/fare_chart/rows/{row_id}", headers=auth["mr1"])).status_code == 403
|
||||
assert (await client.delete(f"{API}/fare_chart/rows/{row_id}", headers=auth["admin"])).status_code == 204
|
||||
assert (await client.get(f"{API}/approvals", headers=auth["am1"])).json() == [] # withdrawn: nothing left for the AM
|
||||
|
||||
async def test_the_pdf_signature_comes_from_the_server_not_the_browser(self, client, auth, org, db, fare_chart):
|
||||
|
||||
@@ -71,7 +71,7 @@ PRINTED_HEADERS = {
|
||||
"VALUE",
|
||||
"CLOSING",
|
||||
"SEC. VALUE",
|
||||
"AUG. SALES",
|
||||
"SALES",
|
||||
"VALUE",
|
||||
],
|
||||
}
|
||||
@@ -126,6 +126,27 @@ def test_product_lists_print_in_their_own_columns():
|
||||
assert cells[1][:4] == ["2", "INTEZOLE-RD", "93.59", "4"]
|
||||
|
||||
|
||||
def test_printing_every_month_together_renumbers_instead_of_repeating():
|
||||
# Each stored the server's own month-reset numbering (1, 1) — printed side by side that
|
||||
# would repeat, so a combined PDF is asked to renumber instead of trusting it.
|
||||
rows = _rows("sales_projection", 0) + [
|
||||
{**{c: "" for c in TABLES["sales_projection"]}, "serial_no": "1", "month": "August", "product_name": "VIVACELLIX-360"},
|
||||
{**{c: "" for c in TABLES["sales_projection"]}, "serial_no": "1", "month": "September", "product_name": "INFEZOX-O"},
|
||||
]
|
||||
body = _ctx("sales_projection", rows, renumber=True)["grids"]["main"]["rows"]
|
||||
assert [r["cells"][0] for r in body[:2]] == ["1", "2"]
|
||||
# A single month's own PDF (no renumber) keeps the server's real stored numbers.
|
||||
body = _ctx("sales_projection", rows, renumber=False)["grids"]["main"]["rows"]
|
||||
assert [r["cells"][0] for r in body[:2]] == ["1", "1"]
|
||||
|
||||
|
||||
def test_sales_projection_sales_column_names_the_actual_month():
|
||||
rows = _rows("sales_projection", 2, month="September")
|
||||
assert _ctx("sales_projection", rows)["grids"]["main"]["headers"][7] == "SEP. SALES"
|
||||
# No month on any row (e.g. a blank template): a generic label, never a hardcoded month.
|
||||
assert _ctx("sales_projection", _rows("sales_projection", 2))["grids"]["main"]["headers"][7] == "SALES"
|
||||
|
||||
|
||||
def test_no_form_prints_dashboard_extras():
|
||||
for table in TABLES:
|
||||
ctx = _ctx(table, _rows(table, 2, pob="5", kilometers_km="9"))
|
||||
|
||||
Reference in New Issue
Block a user