Aduce toate suprafetele dashboard-ului la grila tabelului Trimiteri, muta
navigarea intr-un meniu de cont (hamburger) si da panoului admin actiuni
reale de ciclu de viata. 9 stories, 3 valuri. UI pur (reskin + reasezare)
cu O SINGURA exceptie backend: modelul de stare a contului.
- US-001 sectiunea "Ajutor" eliminata din Acasa (wayfinding redundant).
- US-002 Nomenclator la grila standard (_submissions.html ca referinta).
- US-003 macro autosend compact (Manual<->Auto). Semantica de PREZENTA
`auto_send` (bifat->true, absent->false) NEALTERATA — compatibil cu ambele
parsere (Form(bool) la /mapari, bool(form.get()) la import). Zero backend.
- US-004 accounts.status (pending/active/blocked/archived/deleted), migrare
defensiva idempotenta derivata din `active`, gate worker claim_one pe
status='active' (echivalenta active=1 <=> status='active' pastrata).
- US-005 tabel Mapari compact + panou Ajutor (<details>, proza o singura data),
coloana "In coada".
- US-006 meniu hamburger dropdown (Cont/Integrare/Nomenclator/Admin/logout) +
context is_authenticated/is_admin/csrf_token defensiv in base.html.
- US-007 tab-bar redus la Acasa+Mapari; rutele /_fragments/{cont,integrare,
nomenclator} + deep-link ?tab= raman valide.
- US-008 rute admin block/archive/delete + bulk pe lista account_id,
require_admin + CSRF + PRG, dev id=1 sarit in bulk.
- US-009 admin UI: selectie bife + master + bara bulk + kebab per-rand,
grupare pe stare (bloc nou blocate/arhivate), nota "cont dev implicit" scoasa.
Stergere = SOFT: tombstone (status='deleted'), dar PII purjata IMEDIAT
(rar_creds_enc + chei API revocate + CUI eliberat pentru re-inregistrare),
GDPR/L.142.
VERIFY: 671 teste pass (+40). E2E browser (Playwright) a prins 2 bug-uri
invizibile la TestClient: bara bulk cu display:flex inline invingea [hidden]
(mutat in CSS .bulk-bar[hidden]); conturi arhivate cadeau sub "in asteptare"
(grupare pe status). /code-review high a prins 2 bug-uri reale: soft delete
pastra creds RAR + CUI la nesfarsit fara purjare accounts (GDPR neonorat);
apostrof in numele firmei rupea confirm() inline din kebab — ambele reparate,
plus cleanup boilerplate rute (_lifecycle_route).
Backend trimitere (worker masina stari/idempotenta/mapping) neatins, cu
exceptia gate-ului de cont. Design: docs/design/5.5-uniformizare-ui.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
116 lines
3.9 KiB
Python
116 lines
3.9 KiB
Python
"""Teste US-001 (PRD 3.1): coloana accounts.active + helper-e cont in app/accounts.py."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import tempfile
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture()
|
|
def conn(monkeypatch):
|
|
tmp = tempfile.mkdtemp()
|
|
monkeypatch.setenv("AUTOPASS_DB_PATH", os.path.join(tmp, "test_accounts.db"))
|
|
from app.config import get_settings
|
|
get_settings.cache_clear()
|
|
from app.db import get_connection, init_db
|
|
init_db()
|
|
c = get_connection()
|
|
yield c
|
|
c.close()
|
|
get_settings.cache_clear()
|
|
|
|
|
|
def test_create_account_returneaza_id(conn):
|
|
from app.accounts import create_account
|
|
acct_id = create_account(conn, "Service X")
|
|
assert isinstance(acct_id, int)
|
|
# AUTOINCREMENT peste default id=1 -> primul cont creat are id>=2 (nu atinge default).
|
|
assert acct_id >= 2
|
|
|
|
|
|
def test_create_account_activ_implicit(conn):
|
|
from app.accounts import create_account
|
|
acct_id = create_account(conn, "Service X")
|
|
row = conn.execute("SELECT active FROM accounts WHERE id=?", (acct_id,)).fetchone()
|
|
assert row["active"] == 1
|
|
|
|
|
|
def test_create_account_inactiv(conn):
|
|
from app.accounts import create_account
|
|
acct_id = create_account(conn, "Service X", active=False)
|
|
row = conn.execute("SELECT active FROM accounts WHERE id=?", (acct_id,)).fetchone()
|
|
assert row["active"] == 0
|
|
|
|
|
|
def test_create_account_name_gol_ridica_eroare(conn):
|
|
from app.accounts import create_account
|
|
with pytest.raises(ValueError):
|
|
create_account(conn, " ")
|
|
# nu a inserat nimic peste default
|
|
n = conn.execute("SELECT COUNT(*) AS n FROM accounts").fetchone()["n"]
|
|
assert n == 1
|
|
|
|
|
|
def test_create_account_cui_duplicat_respins(conn):
|
|
from app.accounts import create_account
|
|
first = create_account(conn, "Service A", cui="RO123")
|
|
with pytest.raises(ValueError) as exc:
|
|
create_account(conn, "Service B", cui="RO123")
|
|
# mesaj cu cauza + fix care numeste contul existent (A4)
|
|
msg = str(exc.value)
|
|
assert "RO123" in msg
|
|
assert str(first) in msg
|
|
|
|
|
|
def test_create_cui_null_multiplu_permis(conn):
|
|
from app.accounts import create_account
|
|
a = create_account(conn, "Fara CUI 1")
|
|
b = create_account(conn, "Fara CUI 2")
|
|
assert a != b
|
|
|
|
|
|
def test_create_cui_normalizat(conn):
|
|
from app.accounts import create_account
|
|
create_account(conn, "Service A", cui=" ro123 ")
|
|
# normalizat la RO123 -> duplicat respins indiferent de spatii/caz
|
|
with pytest.raises(ValueError):
|
|
create_account(conn, "Service B", cui="RO123")
|
|
row = conn.execute("SELECT cui FROM accounts WHERE name='Service A'").fetchone()
|
|
assert row["cui"] == "RO123"
|
|
|
|
|
|
def test_set_active_comuta(conn):
|
|
from app.accounts import create_account, set_active
|
|
acct_id = create_account(conn, "Service X")
|
|
set_active(conn, acct_id, False)
|
|
assert conn.execute("SELECT active FROM accounts WHERE id=?", (acct_id,)).fetchone()["active"] == 0
|
|
set_active(conn, acct_id, True)
|
|
assert conn.execute("SELECT active FROM accounts WHERE id=?", (acct_id,)).fetchone()["active"] == 1
|
|
|
|
|
|
def test_set_active_idempotent(conn):
|
|
from app.accounts import create_account, set_active
|
|
acct_id = create_account(conn, "Service X") # deja activ
|
|
set_active(conn, acct_id, True) # nu trebuie sa arunce
|
|
assert conn.execute("SELECT active FROM accounts WHERE id=?", (acct_id,)).fetchone()["active"] == 1
|
|
|
|
|
|
def test_set_active_inexistent_ridica(conn):
|
|
from app.accounts import set_active
|
|
with pytest.raises(ValueError):
|
|
set_active(conn, 9999, True)
|
|
|
|
|
|
def test_list_accounts_ordonat_fara_creds(conn):
|
|
from app.accounts import create_account, list_accounts
|
|
create_account(conn, "Service B")
|
|
create_account(conn, "Service A")
|
|
rows = list_accounts(conn)
|
|
ids = [r["id"] for r in rows]
|
|
assert ids == sorted(ids)
|
|
for r in rows:
|
|
assert "rar_creds_enc" not in r
|
|
assert set(r.keys()) == {"id", "name", "cui", "active", "status", "created_at"}
|