feat(errors): erori pe 3 niveluri (problema+cauza+fix) pe API si UI (PRD 5.4)
Catalog central pur app/errors.py ca sursa unica cod->{problema,fix},
consumat de API+UI+worker. Aditiv (field/message pastrate la octet) +
rar_error stocat superset. Scope: fluxul de declarare; login/signup/CSRF
neatinse. labels.parse_erori degradeaza gratios; UI progresiv AA light+dark.
631 teste.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -157,3 +157,44 @@ def test_shape_invalid_422(client):
|
||||
for err in body.get("detail", []):
|
||||
assert "input" not in err
|
||||
assert "ctx" not in err
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# US-003: 3 niveluri in raspunsul /valideaza #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
def test_erori_au_3niveluri(client):
|
||||
"""/valideaza cu VIN invalid -> erori[i] au cod/problema/cauza/fix (pass-through US-002)."""
|
||||
r = client.post("/v1/prezentari/valideaza", json=_body_v(vin="WVWZZZ1OZIQ45678"))
|
||||
assert r.status_code == 200
|
||||
res = r.json()["results"][0]
|
||||
assert res["status_estimat"] == "needs_data"
|
||||
erori = res["erori"]
|
||||
assert len(erori) >= 1
|
||||
for e in erori:
|
||||
assert "cod" in e, f"lipseste 'cod' in {e}"
|
||||
assert "problema" in e, f"lipseste 'problema' in {e}"
|
||||
assert "cauza" in e, f"lipseste 'cauza' in {e}"
|
||||
assert "fix" in e, f"lipseste 'fix' in {e}"
|
||||
|
||||
|
||||
def test_nemapate_au_3niveluri(client):
|
||||
"""/valideaza cu cod_op nemapat -> nemapate[i] au cod_op_service+denumire PASTRATE
|
||||
+ cod==COD_NEMAPAT + cele 3 niveluri."""
|
||||
prez = _prez()
|
||||
prez["prestatii"] = [{"cod_op_service": "OP_TEST_NEMAPAT", "denumire": "Operatie test"}]
|
||||
r = client.post("/v1/prezentari/valideaza", json={"prezentari": [prez]})
|
||||
assert r.status_code == 200
|
||||
res = r.json()["results"][0]
|
||||
assert res["status_estimat"] == "needs_mapping"
|
||||
nemapate = res["nemapate"]
|
||||
assert len(nemapate) == 1
|
||||
n = nemapate[0]
|
||||
# Campuri originale pastrate
|
||||
assert n["cod_op_service"] == "OP_TEST_NEMAPAT"
|
||||
assert n["denumire"] == "Operatie test"
|
||||
# 3 niveluri adaugate
|
||||
assert n["cod"] == "COD_NEMAPAT"
|
||||
assert n["problema"]
|
||||
assert n["cauza"]
|
||||
assert n["fix"]
|
||||
|
||||
Reference in New Issue
Block a user