mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-24 18:05:07 +00:00
chore(release): promote 6.0.0 to main
This commit is contained in:
@@ -47,30 +47,30 @@ def reset_template():
|
||||
|
||||
def test_air_date_replaces_season_episode_dotted(reset_template):
|
||||
ep = make_episode(air_date=date(2024, 6, 30))
|
||||
ctx = ep._build_template_context(StubMediaInfo())
|
||||
ctx = ep.build_template_context(StubMediaInfo())
|
||||
assert ctx["season_episode"] == "2024.06.30"
|
||||
assert ctx["season"] == "2024.06.30"
|
||||
assert ctx["episode"] == ""
|
||||
assert ctx["year"] == "" # date carries the year
|
||||
assert ctx["date"] == "2024-06-30" # ISO regardless of separator
|
||||
assert ctx["year"] == ""
|
||||
assert ctx["date"] == "2024-06-30"
|
||||
|
||||
|
||||
def test_air_date_uses_space_separator(reset_template):
|
||||
reset_template.output_template = {"series": "{title} {season_episode} {quality}-{tag}"}
|
||||
ep = make_episode(air_date=date(2024, 6, 30))
|
||||
assert ep._build_template_context(StubMediaInfo())["season_episode"] == "2024 06 30"
|
||||
assert ep.build_template_context(StubMediaInfo())["season_episode"] == "2024 06 30"
|
||||
|
||||
|
||||
def test_iso_string_air_date_coerced(reset_template):
|
||||
ep = make_episode(air_date="2024-06-30")
|
||||
assert isinstance(ep.air_date, date)
|
||||
assert ep._build_template_context(StubMediaInfo())["season_episode"] == "2024.06.30"
|
||||
assert ep.build_template_context(StubMediaInfo())["season_episode"] == "2024.06.30"
|
||||
|
||||
|
||||
def test_year_always_dropped_in_file_when_dated(reset_template):
|
||||
"""The air date is the sole date in the filename; a distinct year is dropped too (deterministic)."""
|
||||
ep = make_episode(year=2010, air_date=date(2013, 10, 30))
|
||||
ctx = ep._build_template_context(StubMediaInfo())
|
||||
ctx = ep.build_template_context(StubMediaInfo())
|
||||
assert ctx["year"] == ""
|
||||
assert ctx["season_episode"] == "2013.10.30"
|
||||
|
||||
@@ -78,7 +78,7 @@ def test_year_always_dropped_in_file_when_dated(reset_template):
|
||||
def test_yearless_title_takes_year_from_date(reset_template):
|
||||
"""A title with no year still names cleanly; the date supplies the year."""
|
||||
ep = make_episode(year=None, air_date=date(2026, 6, 28))
|
||||
ctx = ep._build_template_context(StubMediaInfo())
|
||||
ctx = ep.build_template_context(StubMediaInfo())
|
||||
assert ctx["year"] == ""
|
||||
assert ctx["season_episode"] == "2026.06.28"
|
||||
|
||||
@@ -87,13 +87,13 @@ def test_datetime_normalized_to_date(reset_template):
|
||||
"""A datetime (subclass of date) must not leak its time into the {date} token."""
|
||||
ep = make_episode(air_date=datetime(2024, 6, 30, 13, 0, 0))
|
||||
assert type(ep.air_date) is date
|
||||
assert ep._build_template_context(StubMediaInfo())["date"] == "2024-06-30"
|
||||
assert ep.build_template_context(StubMediaInfo())["date"] == "2024-06-30"
|
||||
|
||||
|
||||
def test_no_air_date_is_unchanged(reset_template):
|
||||
"""Regression: without air_date, naming is exactly as before (presentation-only field)."""
|
||||
ep = make_episode()
|
||||
ctx = ep._build_template_context(StubMediaInfo())
|
||||
ctx = ep.build_template_context(StubMediaInfo())
|
||||
assert ctx["season_episode"] == "S2024E181"
|
||||
assert ctx["season"] == "S2024"
|
||||
assert ctx["episode"] == "E181"
|
||||
@@ -106,10 +106,20 @@ def test_dated_folder_groups_by_year(reset_template):
|
||||
reset_template.folder_template = ""
|
||||
folder = make_episode(air_date=date(2024, 6, 30)).get_filename(StubMediaInfo(), folder=True)
|
||||
assert "2024" in folder
|
||||
assert "S2024" not in folder # season folder is the year, not the faked season
|
||||
assert "S2024" not in folder
|
||||
|
||||
|
||||
# --- selection by date ------------------------------------------------------
|
||||
def test_dated_folder_drops_year_matching_air_year(reset_template):
|
||||
"""{year?} would repeat the air-year season label (Title.2024.2024); it must render once."""
|
||||
folder = make_episode(air_date=date(2024, 6, 30)).get_filename(StubMediaInfo(), folder=True)
|
||||
assert "2024.2024" not in folder
|
||||
|
||||
|
||||
def test_dated_folder_keeps_distinct_year(reset_template):
|
||||
"""A series year different from the air year is real information and stays."""
|
||||
folder = make_episode(year=2010, air_date=date(2013, 10, 30)).get_filename(StubMediaInfo(), folder=True)
|
||||
assert "2010" in folder
|
||||
assert "2013" in folder
|
||||
|
||||
|
||||
def test_a_dated_episode_matches_its_iso_date_key():
|
||||
@@ -134,9 +144,6 @@ def test_an_undated_episode_is_unaffected_by_date_keys():
|
||||
assert episode.matches_wanted({"2024x181"})
|
||||
|
||||
|
||||
# --- the air-date guard -----------------------------------------------------
|
||||
|
||||
|
||||
def test_a_pre_1970_air_date_is_rejected():
|
||||
with pytest.raises(ValueError):
|
||||
make_episode(air_date=date(1969, 12, 31))
|
||||
|
||||
Reference in New Issue
Block a user