From 1f5713a232fb47f25d0ee799efd620ada80a4cb0 Mon Sep 17 00:00:00 2001 From: blissful Date: Mon, 6 May 2024 11:15:22 -0400 Subject: [PATCH] new test --- rose/rules.py | 4 ++-- rose/rules_test.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/rose/rules.py b/rose/rules.py index cefe3fa..27373cc 100644 --- a/rose/rules.py +++ b/rose/rules.py @@ -586,9 +586,9 @@ def open_datafile(path: Path) -> StoredDataFile: return # And then let's go for the confirmation. + num_changes = len(actionable_audiotags) + len(actionable_datafiles) if confirm_yes: click.echo() - num_changes = len(actionable_datafiles) + len(actionable_datafiles) if num_changes > enter_number_to_confirm_above_count: while True: userconfirmation = click.prompt( @@ -640,7 +640,7 @@ def open_datafile(path: Path) -> StoredDataFile: logger.info(f"Wrote datafile changes to {pathtext}") click.echo() - click.echo(f"Applied tag changes to {len(actionable_audiotags)} tracks!") + click.echo(f"Applied tag changes to {num_changes} tracks!") # == Step 6: Trigger cache update === diff --git a/rose/rules_test.py b/rose/rules_test.py index 5d0ee81..44ad8af 100644 --- a/rose/rules_test.py +++ b/rose/rules_test.py @@ -7,6 +7,7 @@ from rose.audiotags import AudioTags, RoseDate from rose.cache import ( + get_release, list_releases, list_tracks, update_cache, @@ -192,6 +193,36 @@ def test_rules_fields_match_trackartist(config: Config, source_dir: Path) -> Non assert af.trackartists.main == [Artist("8")] +@pytest.mark.usefixtures("source_dir") +def test_rules_fields_match_new(config: Config) -> None: + rule = MetadataRule.parse("new:false", ["replace:true"]) + execute_metadata_rule(config, rule, confirm_yes=False) + release = get_release(config, "ilovecarly") + assert release + assert release.new + release = get_release(config, "ilovenewjeans") + assert release + assert release.new + + rule = MetadataRule.parse("new:true", ["replace:false"]) + execute_metadata_rule(config, rule, confirm_yes=False) + release = get_release(config, "ilovecarly") + assert release + assert not release.new + release = get_release(config, "ilovenewjeans") + assert release + assert not release.new + + rule = MetadataRule.parse("releasetitle:Carly", ["new/replace:true"]) + execute_metadata_rule(config, rule, confirm_yes=False) + release = get_release(config, "ilovecarly") + assert release + assert release.new + release = get_release(config, "ilovenewjeans") + assert release + assert not release.new + + def test_match_backslash(config: Config, source_dir: Path) -> None: af = AudioTags.from_file(source_dir / "Test Release 1" / "01.m4a") af.tracktitle = r"X \\ Y"