All checks were successful
Deploy Development / deploy (push) Successful in 36s
Test Suite / pytest-backend (push) Successful in 33s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Successful in 47s
Co-authored-by: Cursor <cursoragent@cursor.com>
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
"""Vereins-Übung: Copyright-Pflicht für angehängte Archiv-Dateien."""
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from fastapi import HTTPException
|
|
|
|
import routers.exercises as exercises_mod
|
|
from routers.exercises import apply_club_exercise_media_copyright_rules
|
|
|
|
|
|
def test_apply_club_exercise_media_copyright_skips_non_club() -> None:
|
|
apply_club_exercise_media_copyright_rules(object(), 1, "private")
|
|
|
|
|
|
def test_apply_club_exercise_media_copyright_missing_copyright() -> None:
|
|
orig = exercises_mod._fetch_exercise_linked_file_assets
|
|
|
|
def mock_fetch(_cur, eid: int):
|
|
assert eid == 42
|
|
return [
|
|
{
|
|
"id": 10,
|
|
"visibility": "private",
|
|
"club_id": 1,
|
|
"lifecycle_state": "active",
|
|
"copyright_notice": "",
|
|
"original_filename": "x.jpg",
|
|
}
|
|
]
|
|
|
|
exercises_mod._fetch_exercise_linked_file_assets = mock_fetch
|
|
try:
|
|
with pytest.raises(HTTPException) as ei:
|
|
apply_club_exercise_media_copyright_rules(object(), 42, "club")
|
|
assert ei.value.status_code == 422
|
|
d = ei.value.detail
|
|
assert isinstance(d, dict)
|
|
assert d.get("code") == "CLUB_MEDIA_COPYRIGHT_REQUIRED"
|
|
finally:
|
|
exercises_mod._fetch_exercise_linked_file_assets = orig
|
|
|
|
|
|
def test_apply_club_exercise_media_copyright_ok() -> None:
|
|
orig = exercises_mod._fetch_exercise_linked_file_assets
|
|
|
|
def mock_fetch(_cur, _eid: int):
|
|
return [
|
|
{
|
|
"id": 10,
|
|
"visibility": "private",
|
|
"club_id": 1,
|
|
"lifecycle_state": "active",
|
|
"copyright_notice": "© Verein 2026",
|
|
"original_filename": "x.jpg",
|
|
}
|
|
]
|
|
|
|
exercises_mod._fetch_exercise_linked_file_assets = mock_fetch
|
|
try:
|
|
apply_club_exercise_media_copyright_rules(object(), 42, "club")
|
|
finally:
|
|
exercises_mod._fetch_exercise_linked_file_assets = orig
|