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(
|
||||
|
||||
Reference in New Issue
Block a user