fix: harden admin employee views against malformed data
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user