Medien: library-Pfade nach Medientyp (image/video/pdf/other) unterteilen
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8d85649cf8
commit
3e4fa0dc39
6 files changed
+89
-20
No files matched your search
@@ -3,31 +3,49 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from media_storage import library_storage_key
|
||||
from media_storage import library_media_kind_dir, library_storage_key
|
||||
|
||||
_HEX64 = "a" * 64
|
||||
|
||||
|
||||
def test_library_media_kind_dir_mime_overrides_ext() -> None:
|
||||
assert library_media_kind_dir("image/png", ".bin") == "image"
|
||||
assert library_media_kind_dir("application/pdf", ".tmp") == "pdf"
|
||||
|
||||
|
||||
def test_library_storage_key_private_is_uploader_under_club() -> None:
|
||||
assert (
|
||||
library_storage_key("private", 7, _HEX64, ".jpg", uploader_profile_id=99)
|
||||
== f"library/club/c7/u99/{_HEX64}.jpg"
|
||||
== f"library/club/c7/u99/image/{_HEX64}.jpg"
|
||||
)
|
||||
|
||||
|
||||
def test_library_storage_key_club_flat_under_club() -> None:
|
||||
assert library_storage_key("club", 42, _HEX64, ".png") == f"library/club/c42/{_HEX64}.png"
|
||||
assert (
|
||||
library_storage_key("club", 42, _HEX64, ".png")
|
||||
== f"library/club/c42/image/{_HEX64}.png"
|
||||
)
|
||||
|
||||
|
||||
def test_library_storage_key_official() -> None:
|
||||
assert (
|
||||
library_storage_key("official", None, _HEX64, ".mp4", uploader_profile_id=1)
|
||||
== f"library/official/{_HEX64}.mp4"
|
||||
== f"library/official/video/{_HEX64}.mp4"
|
||||
)
|
||||
|
||||
|
||||
def test_library_storage_key_normalizes_visibility() -> None:
|
||||
assert library_storage_key(" CLUB ", 1, _HEX64, "pdf") == f"library/club/c1/{_HEX64}.pdf"
|
||||
assert (
|
||||
library_storage_key(" CLUB ", 1, _HEX64, "pdf")
|
||||
== f"library/club/c1/pdf/{_HEX64}.pdf"
|
||||
)
|
||||
|
||||
|
||||
def test_library_storage_key_other_bin() -> None:
|
||||
assert (
|
||||
library_storage_key("official", None, _HEX64, "", mime_type="application/octet-stream")
|
||||
== f"library/official/other/{_HEX64}.bin"
|
||||
)
|
||||
|
||||
|
||||
def test_library_storage_key_private_requires_uploader() -> None:
|
||||
|
||||
@@ -16,9 +16,9 @@ from main import app
|
||||
from tenant_context import TenantContext, get_tenant_context
|
||||
|
||||
# Gültige storage_key-Beispiele (64 Hex-Zeichen wie echter SHA-256)
|
||||
_SK_OFF_A = f"library/official/{'a' * 64}.jpg"
|
||||
_SK_OFF_B = f"library/official/{'b' * 64}.jpg"
|
||||
_SK_PRIV_C = f"library/club/c1/u1/{'c' * 64}.mp4"
|
||||
_SK_OFF_A = f"library/official/image/{'a' * 64}.jpg"
|
||||
_SK_OFF_B = f"library/official/image/{'b' * 64}.jpg"
|
||||
_SK_PRIV_C = f"library/club/c1/u1/video/{'c' * 64}.mp4"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in new issue
Block a user