Skip to content

Commit

Permalink
Refactor some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef-Friedrich committed Jan 18, 2024
1 parent bc102f7 commit 3db9901
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions tests/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ def test_no_whitespace_legacy(self, cwd_tmpdir: Path) -> None:
assert filename in stdout

def test_no_whitespace(self, cwd_tmpdir: Path) -> None:
stdout: str = Cli(
"--rename", "--no-whitespace", get_file("meta-real-world.mscz", 4)
).stdout()
stdout: str = (
Cli("--rename", "--no-whitespace")
.append_score("meta-real-world.mscz")
.stdout()
)
filename = "Wir-sind-des-Geyers-schwarze-Haufen (Florian-Geyer).mscz"
assert Path(cwd_tmpdir / filename).exists()
assert filename in stdout
Expand All @@ -138,19 +140,24 @@ def test_alphanum_legacy(self, cwd_tmpdir: Path) -> None:
assert filename in stdout

def test_alphanum(self, cwd_tmpdir: Path) -> None:
stdout: str = Cli(
"--rename", "--alphanum", get_file("meta-all-values.mscz", 4)
).stdout()
stdout: str = (
Cli(
"--rename",
"--alphanum",
)
.append_score("meta-all-values.mscz")
.stdout()
)
filename = "vbox title (vbox composer).mscz"
assert Path(cwd_tmpdir / filename).exists()
assert filename in stdout

@pytest.mark.legacy
def test_ascii_legacy(self, cwd_tmpdir: Path) -> None:
stdout: str = Cli(
"rename", "--ascii", legacy=True
).append_score("unicode.mscz").stdout()
filename = "Tuetlae (Coempoesser).mscz"
"rename", "--ascii", get_file("unicode.mscx"), legacy=True
).stdout()
filename = "Tuetlae (Coempoesser).mscx"
assert Path(cwd_tmpdir / filename).exists()
assert filename in stdout

Expand Down Expand Up @@ -191,26 +198,6 @@ def test_rename_same_filename(self, cwd_tmpdir: Path) -> None:
assert Path(cwd_tmpdir / "same2.mscx").exists()
assert Path(cwd_tmpdir / "same3.mscx").exists()

@pytest.mark.legacy
def test_rename_target_legacy(self, score: Score, cwd_tmpdir: Path) -> None:
Cli(
"rename",
"--target",
cwd_tmpdir,
score,
append_score=False,
legacy=True,
).execute()
target: Path = cwd_tmpdir / "Title (Composer).mscz"
assert target.exists()

def test_rename_target(self, score: Score, cwd_tmpdir: Path) -> None:
Cli("--rename", "--target", cwd_tmpdir, score, append_score=False).execute()
target: Path = cwd_tmpdir / "Title (Composer).mscz"
assert target.exists()


class TestOptionSkipIfEmpty:
@pytest.mark.legacy
def test_rename_skips_legacy(self) -> None:
assert (
Expand Down Expand Up @@ -262,3 +249,21 @@ def test_rename_skip_pass(self, cwd_tmpdir: Path) -> None:
assert target.exists()
assert "score.mscz -> " in stdout
assert filename in stdout

@pytest.mark.legacy
def test_rename_target_legacy(self, score: Score, cwd_tmpdir: Path) -> None:
Cli(
"rename",
"--target",
cwd_tmpdir,
score,
append_score=False,
legacy=True,
).execute()
target: Path = cwd_tmpdir / "Title (Composer).mscz"
assert target.exists()

def test_rename_target(self, score: Score, cwd_tmpdir: Path) -> None:
Cli("--rename", "--target", cwd_tmpdir, score, append_score=False).execute()
target: Path = cwd_tmpdir / "Title (Composer).mscz"
assert target.exists()

0 comments on commit 3db9901

Please sign in to comment.