-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest_filenames.py
52 lines (46 loc) · 1.87 KB
/
test_filenames.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pytest
from podcast_archiver.config import Settings
from podcast_archiver.models.episode import Episode
from podcast_archiver.models.feed import FeedInfo
from podcast_archiver.utils import FilenameFormatter
FEED_INFO = FeedInfo(
title="That\\Show",
subtitle="The one that never comes/came to be",
author="TheJanwShow",
language="de-DE",
)
@pytest.mark.parametrize(
"fname_tmpl,slugify,expected_fname",
[
(
"{show.title}/{episode.published_time:%Y-%m-%d %H%M%S %Z} - {episode.title}.{ext}",
False,
"That-Show/2023-03-12 123456 UTC - Some Episode.mp3",
),
(
"{show.title}/{episode.published_time:%Y-%m-%d %H%M%S %Z} - {episode.title}.{ext}",
True,
"That-Show/2023-03-12-123456-UTC - Some-Episode.mp3",
),
(
"{show.author} - {show.subtitle}/{show.language} - {episode.published_time} - {episode.author}.{ext}",
False,
"TheJanwShow - The one that never comes-came to be/de-DE - 2023-03-12 - Janw.mp3",
),
(
"{show.author}--{show.subtitle}/{show.language}--{episode.published_time}--{episode.author}.{ext}",
True,
"TheJanwShow--The-one-that-never-comes-came-to-be/de-DE--2023-03-12--Janw.mp3",
),
(
"{show.author} -- {show.subtitle}/{episode.published_time} {episode.original_filename}",
False,
"TheJanwShow -- The one that never comes-came to be/2023-03-12 file.mp3",
),
],
)
def test_filename_formatting(fname_tmpl: str, slugify: bool, expected_fname: str, episode: Episode) -> None:
settings = Settings(filename_template=fname_tmpl, slugify_paths=slugify)
formatter = FilenameFormatter(settings=settings)
result = formatter.format(episode, feed_info=FEED_INFO)
assert str(result) == expected_fname