Skip to content

Commit

Permalink
new test
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed May 6, 2024
1 parent 93eaf62 commit 1f5713a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rose/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 ===

Expand Down
31 changes: 31 additions & 0 deletions rose/rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from rose.audiotags import AudioTags, RoseDate
from rose.cache import (
get_release,
list_releases,
list_tracks,
update_cache,
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 1f5713a

Please sign in to comment.