kaledonya clips: a Discord-friendly clip site on top of Zipline

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
esefandClaude Opus 5.5 committed 2026-10-07 20:46:48 +03:00
commit e6f8905377
34 files changed
+2917

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import pytest
from app.names import clean_name, next_free_name, split_name
@pytest.mark.parametrize(
"raw, expected",
[
("2026-10-01 21-33-07.mkv", "2026-10-01-21-33-07.mkv"),
("my clip\tfinal.mp4", "my-clip-final.mp4"),
(" padded.mp4 ", "padded.mp4"),
("C:\\Users\\alice\\Videos\\a b.mp4", "a-b.mp4"),
("dir/sub/x y.png", "x-y.png"),
("çılgın an #1.mp4", "çılgın-an-#1.mp4"),
("", "upload"),
(" ", "upload"),
],
)
def test_clean_name(raw, expected):
assert clean_name(raw) == expected
def test_split_name():
assert split_name("clip.mp4") == ("clip", ".mp4")
assert split_name("a.b.mkv") == ("a.b", ".mkv")
def test_split_name_edge_cases():
assert split_name("README") == ("README", "")
assert split_name(".mp4") == (".mp4", "")
def test_next_free_name_free():
assert next_free_name("clip", ".mp4", lambda n: False) == "clip.mp4"
def test_next_free_name_suffixes():
taken = {"clip.mp4", "clip-2.mp4"}
assert next_free_name("clip", ".mp4", taken.__contains__) == "clip-3.mp4"
def test_next_free_name_no_extension():
assert next_free_name("README", "", {"README"}.__contains__) == "README-2"
def test_next_free_name_gives_up():
with pytest.raises(RuntimeError):
next_free_name("x", ".mp4", lambda n: True, limit=5)