fix: harden admin employee views against malformed data

This commit is contained in:
Anton
2026-04-29 11:11:57 +03:00
parent ce90414654
commit 7530cbdb60
5 changed files with 49 additions and 16 deletions

View File

@@ -94,6 +94,26 @@ def test_employee_detail_payload_normalizes_human_readable_sections(db_session):
assert payload["sections"][3]["paragraphs"] == ["Fallback text"]
def test_employee_payloads_tolerate_malformed_current_data(db_session):
employee = Employee(
profile_key="staff:broken",
canonical_url="https://www.hse.ru/staff/broken",
full_name="Broken Data",
status="active",
first_seen_at=datetime.now(timezone.utc),
last_seen_at=datetime.now(timezone.utc),
current_data="not-a-dict",
)
display = employee_display_payload(employee)
detail = employee_detail_payload(employee)
assert display["positions"] == []
assert display["email_text"] == ""
assert detail["contacts"]["emails"] == []
assert detail["sections"] == []
def test_list_employees_page_filters_sorts_and_paginates(db_session):
db_session.add(
Employee(

View File

@@ -18,7 +18,7 @@ def test_health_returns_versions():
response = client.get("/api/health")
assert response.status_code == 200
assert response.json()["backend_version"] == "0.2.2"
assert response.json()["backend_version"] == "0.2.3"
def test_mcp_requires_token_and_lists_tools():