fix(P-13): repair 3 failing CI pytest tests for content_reports
Deploy Development / deploy (push) Successful in 37s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Successful in 59s

- Add early 403 in set_legal_hold_from_report for plain admin (before DB
  call), fixing test_legal_hold_from_report_requires_superadmin
- Update test_list_inbox_requires_platform_admin to mock DB COUNT query
  (returns cnt=0) so it exercises the club_admin code path correctly
- Extend test_patch_report_under_review mock row with target_type,
  target_id, resolution_note fields now required by the audit-log path

version: 0.8.94
module:  content_reports 1.5.1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 4.6 committed 2026-05-11 22:25:23 +02:00
1 parent 5cf61289ec
commit 56fc6d853d
4 files changed
+39 -7

No files matched your search

+21 -4
View File
@@ -208,8 +208,22 @@ def test_list_inbox_requires_platform_admin():
from routers.content_reports import list_inbox_content_reports
tenant = MagicMock()
tenant.global_role = "trainer"
with pytest.raises(HTTPException) as exc:
list_inbox_content_reports(tenant=tenant)
tenant.profile_id = 99
# COUNT-Abfrage fuer Club-Admin-Rollen → 0 → 403
cnt_row = _row({"cnt": 0})
mock_cur = MagicMock()
mock_cur.fetchone.return_value = cnt_row
mock_conn = MagicMock()
mock_conn_ctx = MagicMock()
mock_conn_ctx.__enter__ = MagicMock(return_value=mock_conn)
mock_conn_ctx.__exit__ = MagicMock(return_value=False)
with patch("routers.content_reports.get_db", return_value=mock_conn_ctx), \
patch("routers.content_reports.get_cursor", return_value=mock_cur):
with pytest.raises(HTTPException) as exc:
list_inbox_content_reports(tenant=tenant)
assert exc.value.status_code == 403
@@ -252,8 +266,11 @@ def test_patch_report_under_review():
body = ContentReportPatch(status="under_review")
existing_row = MagicMock()
existing_row.__getitem__ = lambda s, k: {"id": 5, "status": "submitted"}[k]
existing_row.keys = lambda: ["id", "status"]
existing_row.__getitem__ = lambda s, k: {
"id": 5, "status": "submitted",
"target_type": "media_asset", "target_id": 42, "resolution_note": None,
}[k]
existing_row.keys = lambda: ["id", "status", "target_type", "target_id", "resolution_note"]
updated_row = MagicMock()
updated_row.__getitem__ = lambda s, k: {"id": 5, "status": "under_review"}[k]