From a5054bfdff10aaccc64c84999e78ff26e1bf5b98 Mon Sep 17 00:00:00 2001 From: blissful Date: Sat, 20 Apr 2024 13:22:50 -0400 Subject: [PATCH] fix tests --- rose/audiotags.py | 16 ++++++++-------- rose/releases_test.py | 2 +- rose/templates_test.py | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/rose/audiotags.py b/rose/audiotags.py index cf367a5..1556380 100644 --- a/rose/audiotags.py +++ b/rose/audiotags.py @@ -307,18 +307,18 @@ def _write_tag_with_description(name: str, value: str | None) -> None: m.tags = mutagen.mp4.MP4Tags() m.tags["----:net.sunsetglow.rose:ID"] = (self.id or "").encode() m.tags["----:net.sunsetglow.rose:RELEASEID"] = (self.release_id or "").encode() - m.tags["\xa9nam"] = (self.title or "").encode() - m.tags["\xa9day"] = str(self.releaseyear).zfill(4).encode() + m.tags["\xa9nam"] = self.title or "" + m.tags["\xa9day"] = str(self.releaseyear).zfill(4) m.tags["----:net.sunsetglow.rose:COMPOSITIONYEAR"] = ( str(self.compositionyear).zfill(4).encode() ) - m.tags["\xa9alb"] = (self.release or "").encode() - m.tags["\xa9gen"] = ";".join(self.genre).encode() + m.tags["\xa9alb"] = self.release or "" + m.tags["\xa9gen"] = ";".join(self.genre) m.tags["----:com.apple.iTunes:LABEL"] = ";".join(self.label).encode() m.tags["----:com.apple.iTunes:CATALOGNUMBER"] = (self.catalognumber or "").encode() m.tags["----:com.apple.iTunes:RELEASETYPE"] = self.releasetype.encode() - m.tags["aART"] = format_artist_string(self.releaseartists).encode() - m.tags["\xa9ART"] = format_artist_string(self.trackartists).encode() + m.tags["aART"] = format_artist_string(self.releaseartists) + m.tags["\xa9ART"] = format_artist_string(self.trackartists) # Wipe the alt. role artist tags, since we encode the full artist into the main tag. with contextlib.suppress(KeyError): del m.tags["----:com.apple.iTunes:REMIXER"] @@ -417,8 +417,8 @@ def _get_tag(t: Any, keys: list[str], *, split: bool = False, first: bool = Fals f"Encountered a tag value of type {type(val)}" ) if first: - return values[0] if values else None - return r" \\ ".join(values) + return (values[0] or None) if values else None + return r" \\ ".join(values) or None except (KeyError, ValueError): pass return None diff --git a/rose/releases_test.py b/rose/releases_test.py index 48357f9..f6450ff 100644 --- a/rose/releases_test.py +++ b/rose/releases_test.py @@ -182,7 +182,7 @@ def test_edit_release(monkeypatch: Any, config: Config, source_dir: Path) -> Non releasetype="single", releaseyear=2222, compositionyear=1800, - catalognumber="lalala", + catalognumber="Lalala", new=False, disctotal=1, genres=["J-Pop", "Pop-Rap"], diff --git a/rose/templates_test.py b/rose/templates_test.py index 532031b..c782421 100644 --- a/rose/templates_test.py +++ b/rose/templates_test.py @@ -115,61 +115,78 @@ def test_preview_templates(config: Config) -> None: Source Directory - Release: Sample 1: Kim Lip - 2017. Kim Lip - Single [NEW] Sample 2: BTS - 2016. Young Forever (花樣年華) + Sample 3: Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - 1992. Images Source Directory - Track: Sample 1: 01. Eclipse.opus Sample 2: 02-05. House of Cards.opus + Sample 3: 01-01. Gigues: Modéré.opus.opus 1. All Releases - Release: Sample 1: Kim Lip - 2017. Kim Lip - Single [NEW] Sample 2: BTS - 2016. Young Forever (花樣年華) + Sample 3: Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - 1992. Images 1. All Releases - Track: Sample 1: 01. Eclipse.opus Sample 2: 02-05. House of Cards.opus + Sample 3: 01-01. Gigues: Modéré.opus.opus 2. New Releases - Release: Sample 1: Kim Lip - 2017. Kim Lip - Single [NEW] Sample 2: BTS - 2016. Young Forever (花樣年華) + Sample 3: Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - 1992. Images 2. New Releases - Track: Sample 1: 01. Eclipse.opus Sample 2: 02-05. House of Cards.opus + Sample 3: 01-01. Gigues: Modéré.opus.opus 3. Recently Added Releases - Release: Sample 1: [2023-04-20] Kim Lip - 2017. Kim Lip - Single [NEW] Sample 2: [2023-06-09] BTS - 2016. Young Forever (花樣年華) + Sample 3: [2023-09-06] Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - 1992. Images 3. Recently Added Releases - Track: Sample 1: 01. Eclipse.opus Sample 2: 02-05. House of Cards.opus + Sample 3: 01-01. Gigues: Modéré.opus.opus 4. Artists - Release: Sample 1: Kim Lip - 2017. Kim Lip - Single [NEW] Sample 2: BTS - 2016. Young Forever (花樣年華) + Sample 3: Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - 1992. Images 4. Artists - Track: Sample 1: 01. Eclipse.opus Sample 2: 02-05. House of Cards.opus + Sample 3: 01-01. Gigues: Modéré.opus.opus 5. Genres - Release: Sample 1: Kim Lip - 2017. Kim Lip - Single [NEW] Sample 2: BTS - 2016. Young Forever (花樣年華) + Sample 3: Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - 1992. Images 5. Genres - Track: Sample 1: 01. Eclipse.opus Sample 2: 02-05. House of Cards.opus + Sample 3: 01-01. Gigues: Modéré.opus.opus 6. Labels - Release: Sample 1: Kim Lip - 2017. Kim Lip - Single [NEW] Sample 2: BTS - 2016. Young Forever (花樣年華) + Sample 3: Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - 1992. Images 6. Labels - Track: Sample 1: 01. Eclipse.opus Sample 2: 02-05. House of Cards.opus + Sample 3: 01-01. Gigues: Modéré.opus.opus 7. Collages - Release: Sample 1: 1. Kim Lip - 2017. Kim Lip - Single [NEW] Sample 2: 2. BTS - 2016. Young Forever (花樣年華) + Sample 3: 3. Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - 1992. Images 7. Collages - Track: Sample 1: 01. Eclipse.opus Sample 2: 02-05. House of Cards.opus + Sample 3: 01-01. Gigues: Modéré.opus.opus 8. Playlists - Track: Sample 1: 1. Kim Lip - Eclipse.opus Sample 2: 2. BTS - House of Cards.opus + Sample 3: 3. Claude Debussy performed by Cleveland Orchestra under Pierre Boulez - Gigues: Modéré.opus.opus """ )