Curatare globala a comentariilor si docstring-urilor (app, tools, teste, scripturi): eliminate referintele la PRD-uri, US-xxx, task-uri istorice si review-uri; pastrata doar informatia functionala, formulata scurt. Regula adaugata in CLAUDE.md (sectiunea Stil). Fara modificari de cod sau comportament. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
85 lines
3.4 KiB
Python
85 lines
3.4 KiB
Python
"""
|
|
Teste pentru eticheta randurilor tinute manual (held).
|
|
|
|
Regula de afisaj:
|
|
- `status='queued' AND held=1` -> "In asteptare (manual)" + clasa CSS de
|
|
AVERTIZARE (amber, `--warn`) — asteptare benigna, NU eroare (rosu).
|
|
- `held=0` (sau lipsa) -> comportament neschimbat pentru TOATE starile.
|
|
- `held` NU e stare noua in masina de stari: CHECK-ul din schema ramane neatins.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from app.web.labels import eticheta_scurta, eticheta_stare
|
|
|
|
|
|
TEXT_HELD = "In asteptare (manual)"
|
|
# Clasa CSS amber (--warn) reutilizata din base.html (.s-needs_review{color:var(--warn)}).
|
|
# NU e o clasa needs_* rosie (s-needs_data / s-needs_mapping sunt --err).
|
|
CLASA_WARN_HELD = "s-needs_review"
|
|
|
|
# Toate starile non-queued: held nu trebuie sa le schimbe niciodata.
|
|
STARI_NEAFECTATE = ["sending", "sent", "needs_mapping", "needs_data", "error"]
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# eticheta_stare (text lung + subtext + clasa)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
def test_queued_held_are_eticheta_manuala_si_clasa_warn():
|
|
text, subtext, css_class = eticheta_stare("queued", held=True)
|
|
assert text == TEXT_HELD, f"asteptam {TEXT_HELD!r}, got {text!r}"
|
|
assert css_class == CLASA_WARN_HELD, (
|
|
f"randul tinut trebuie amber (--warn) prin {CLASA_WARN_HELD!r}, got {css_class!r}"
|
|
)
|
|
# Nu trebuie sa fie o clasa de eroare rosie.
|
|
assert css_class not in ("s-error", "s-needs_data", "s-needs_mapping"), (
|
|
"held e asteptare benigna — nu trebuie sa foloseasca o clasa rosie de eroare"
|
|
)
|
|
assert isinstance(subtext, str)
|
|
|
|
|
|
def test_queued_held_false_ramane_neschimbat():
|
|
"""queued fara held == comportamentul dinainte de introducerea held."""
|
|
fara_held = eticheta_stare("queued")
|
|
held_false = eticheta_stare("queued", held=False)
|
|
assert fara_held == held_false, "held=False trebuie identic cu apelul fara held"
|
|
text, _subtext, css_class = held_false
|
|
assert "In asteptare" in text
|
|
assert text != TEXT_HELD, "queued normal NU trebuie sa afiseze varianta manuala"
|
|
assert css_class == "s-queued"
|
|
|
|
|
|
@pytest.mark.parametrize("status", STARI_NEAFECTATE)
|
|
def test_alte_stari_ignora_held(status):
|
|
"""held nu are efect pe nicio stare in afara de queued."""
|
|
assert eticheta_stare(status, held=True) == eticheta_stare(status, held=False)
|
|
assert eticheta_stare(status, held=True) == eticheta_stare(status)
|
|
|
|
|
|
def test_apel_pozitional_compat():
|
|
"""Semnatura pastreaza compatibilitatea: apelul vechi cu un singur arg merge."""
|
|
assert eticheta_stare("sent") == eticheta_stare("sent", held=False)
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# eticheta_scurta (pill) — pill-ul trebuie sa distinga held de queued normal
|
|
# ---------------------------------------------------------------------------
|
|
|
|
def test_pill_queued_held_diferit_de_queued_normal():
|
|
pill_held = eticheta_scurta("queued", held=True)
|
|
pill_normal = eticheta_scurta("queued", held=False)
|
|
assert pill_held != pill_normal, (
|
|
"pill-ul trebuie sa distinga randul tinut (altfel randa 'In coada' identic)"
|
|
)
|
|
assert pill_normal == "In coada"
|
|
|
|
|
|
def test_pill_alte_stari_ignora_held():
|
|
for status in STARI_NEAFECTATE:
|
|
assert eticheta_scurta(status, held=True) == eticheta_scurta(status, held=False)
|
|
|
|
|
|
def test_pill_apel_pozitional_compat():
|
|
assert eticheta_scurta("queued") == eticheta_scurta("queued", held=False)
|