From ec45ff7b76b301bcec48274681242eb62a188d69 Mon Sep 17 00:00:00 2001 From: Josef Friedrich Date: Sat, 27 Jan 2024 10:40:12 +0100 Subject: [PATCH] Get rid of legacy --- tests/helper.py | 18 +-- tests/test_lyrics.py | 3 +- tests/test_meta.py | 375 ++++++++++++++++++------------------------- 3 files changed, 164 insertions(+), 232 deletions(-) diff --git a/tests/helper.py b/tests/helper.py index 75b6f76..73db646 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -132,14 +132,10 @@ class Cli: __executed: bool = False __stdout: Optional[str] = None __stderr: Optional[str] = None - __legacy: bool = False __append_score: bool - def __init__( - self, *args: CliArg, append_score: bool = True, legacy: bool = False - ) -> None: + def __init__(self, *args: CliArg, append_score: bool = True) -> None: self.__args = list(args) - self.__legacy = legacy self.__append_score = append_score def __set_score(self, score: Score, append_to_args: bool = False) -> Score: @@ -191,11 +187,7 @@ def __execute(self) -> None: stdout = StringIO() stderr = StringIO() with redirect_stdout(stdout), redirect_stderr(stderr): - if self.__legacy: - pass - # execute_legacy(self.__stringified_args) - else: - execute(self.__stringified_args) + execute(self.__stringified_args) if self.__score is not None: self.__score = self.__score.reload() self.__stdout = stdout.getvalue() @@ -236,12 +228,8 @@ def stderr(self) -> str: def sysexit(self) -> str: if not self.__executed: - script_name = "musescore-manager" - if self.__legacy: - script_name = "mscx-manager" - result = subprocess.run( - [script_name] + self.__stringified_args, + ["musescore-manager"] + self.__stringified_args, capture_output=True, encoding="utf-8", ) diff --git a/tests/test_lyrics.py b/tests/test_lyrics.py index c731476..b5540d5 100644 --- a/tests/test_lyrics.py +++ b/tests/test_lyrics.py @@ -110,11 +110,10 @@ def test_fix(version: int) -> None: ] -@pytest.mark.skip("Will be fixed later") def test_remap() -> None: score = helper.get_score("lyrics-remap.mscx") - Cli("lyrics", "--remap", "2:6", score, legacy=True).execute() + Cli("--remap-lyrics", "2:6", score).execute() new_score = score.reload() nos: list[int] = [] diff --git a/tests/test_meta.py b/tests/test_meta.py index 5c450d4..4df26b6 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -20,7 +20,7 @@ ) from mscxyz.score import Score from tests import helper -from tests.helper import Cli, ini_file +from tests.helper import Cli def reload(src: Score | str | Path) -> Interface: @@ -423,227 +423,172 @@ def test_clean_some_fields(self) -> None: class TestStdout: - def test_show(self) -> None: + def test_verbose_0(self) -> None: + stdout = Cli("--clean-meta", "all").stdout() + assert stdout == "" + + def test_verbose_1(self) -> None: stdout = ( - Cli( - "-v", - "--clean-meta", - "all", - ) + Cli("-v", "--clean-meta", "all") .append_score("meta-all-values.mscz") .stdout() ) lines = stdout.splitlines() assert lines[0] == "" assert "vbox_title: “vbox_title” ->" in stdout - - @pytest.mark.skip("Will be fixed later") - def test_show_simple_unverbose(self) -> None: - stdout = Cli( - "--config-file", - ini_file, - "meta", - "--clean", - "all", - legacy=True, - ).stdout() - lines = stdout.splitlines() - assert lines[0] == "" - assert "score.mscz" in stdout - assert lines[2] == "combined_composer: “Composer” -> “”" - assert lines[3] == "combined_title: “Title” -> “”" - assert lines[-1] == "vbox_title: “Title” -> “”" - - @pytest.mark.skip("Will be fixed later") - def test_show_verbose(self) -> None: - stdout = Cli( - "--config-file", - ini_file, - "--verbose", - "meta", - "--clean", - "all", - legacy=True, - ).stdout() - lines = stdout.splitlines() - assert lines[0] == "" - assert "score.mscz" in stdout - assert lines[2] == "combined_composer: “Composer” -> “”" - assert lines[3] == "combined_lyricist: " - assert lines[-2] == "vbox_subtitle: " - assert lines[-1] == "vbox_title: “Title” -> “”" - - @pytest.mark.skip("Will be fixed later") - def test_show_verbose_zero(self) -> None: - stdout = Cli("meta", "--clean", "all", legacy=True).stdout() - assert "readonly_basename" in stdout - assert "readonly_abspath" not in stdout - assert "readonly_relpath_backup" not in stdout - - @pytest.mark.skip("Will be fixed later") - def test_show_verbose_one(self) -> None: - stdout = Cli("-v", "meta", "--clean", "all", legacy=True).stdout() - assert "readonly_abspath" in stdout - assert "readonly_relpath_backup" not in stdout - - @pytest.mark.skip("Will be fixed later") - def test_show_verbose_two(self) -> None: - assert ( - "readonly_relpath_backup" - in Cli( - "-vv", - "meta", - "--clean", - "all", - legacy=True, - ).stdout() - ) - - def test_option_metatag(self) -> None: - score = Cli( - "--metatag", - "arranger", - "a", - # - "--metatag", - "audio_com_url", - "acu", - # - "--metatag", - "composer", - "c", - # - "--metatag", - "copyright", - "c", - # - "--metatag", - "creation_date", - "cd", - # - "--metatag", - "lyricist", - "l", - # - "--metatag", - "movement_number", - "mn", - # - "--metatag", - "movement_title", - "mt", - # - "--metatag", - "msc_version", - "mv", - # - "--metatag", - "platform", - "p", - # - "--metatag", - "poet", - "p", - # - "--metatag", - "source", - "s", - # - "--metatag", - "source_revision_id", - "sri", - # - "--metatag", - "subtitle", - "s", - # - "--metatag", - "translator", - "t", - # - "--metatag", - "work_number", - "wn", - # - "--metatag", - "work_title", - "wt", - ).score() - - m = score.meta.metatag - assert m.arranger == "a" - assert m.audio_com_url == "acu" - assert m.composer == "c" - assert m.copyright == "c" - assert m.creation_date == "cd" - assert m.lyricist == "l" - assert m.movement_number == "mn" - assert m.movement_title == "mt" - assert m.msc_version == "mv" - assert m.platform == "p" - assert m.poet == "p" - assert m.source == "s" - assert m.source_revision_id == "sri" - assert m.subtitle == "s" - assert m.translator == "t" - assert m.work_number == "wn" - assert m.work_title == "wt" - - def test_option_vbox(self) -> None: - score = Cli( - "--vbox", - "composer", - "c", - # - "--vbox", - "lyricist", - "l", - # - "--vbox", - "subtitle", - "s", - # - "--vbox", - "title", - "t", - ).score() - - v = score.meta.vbox - assert v.composer == "c" - assert v.lyricist == "l" - assert v.subtitle == "s" - assert v.title == "t" - - def test_option_combined(self) -> None: - score = Cli( - "--combined", - "composer", - "c", - # - "--combined", - "lyricist", - "l", - # - "--combined", - "subtitle", - "s", - # - "--combined", - "title", - "t", - ).score() - - m = score.meta.metatag - assert m.composer == "c" - assert m.lyricist == "l" - assert m.movement_title == "s" - assert m.work_title == "t" - - v = score.meta.vbox - assert v.composer == "c" - assert v.lyricist == "l" - assert v.subtitle == "s" - assert v.title == "t" + assert "path: " not in stdout + + def test_verbose_2(self) -> None: + assert "path: " in Cli("-vv", "--clean-meta", "all").stdout() + + +def test_option_metatag() -> None: + score = Cli( + "--metatag", + "arranger", + "a", + # + "--metatag", + "audio_com_url", + "acu", + # + "--metatag", + "composer", + "c", + # + "--metatag", + "copyright", + "c", + # + "--metatag", + "creation_date", + "cd", + # + "--metatag", + "lyricist", + "l", + # + "--metatag", + "movement_number", + "mn", + # + "--metatag", + "movement_title", + "mt", + # + "--metatag", + "msc_version", + "mv", + # + "--metatag", + "platform", + "p", + # + "--metatag", + "poet", + "p", + # + "--metatag", + "source", + "s", + # + "--metatag", + "source_revision_id", + "sri", + # + "--metatag", + "subtitle", + "s", + # + "--metatag", + "translator", + "t", + # + "--metatag", + "work_number", + "wn", + # + "--metatag", + "work_title", + "wt", + ).score() + + m = score.meta.metatag + assert m.arranger == "a" + assert m.audio_com_url == "acu" + assert m.composer == "c" + assert m.copyright == "c" + assert m.creation_date == "cd" + assert m.lyricist == "l" + assert m.movement_number == "mn" + assert m.movement_title == "mt" + assert m.msc_version == "mv" + assert m.platform == "p" + assert m.poet == "p" + assert m.source == "s" + assert m.source_revision_id == "sri" + assert m.subtitle == "s" + assert m.translator == "t" + assert m.work_number == "wn" + assert m.work_title == "wt" + + +def test_option_vbox() -> None: + score = Cli( + "--vbox", + "composer", + "c", + # + "--vbox", + "lyricist", + "l", + # + "--vbox", + "subtitle", + "s", + # + "--vbox", + "title", + "t", + ).score() + + v = score.meta.vbox + assert v.composer == "c" + assert v.lyricist == "l" + assert v.subtitle == "s" + assert v.title == "t" + + +def test_option_combined() -> None: + score = Cli( + "--combined", + "composer", + "c", + # + "--combined", + "lyricist", + "l", + # + "--combined", + "subtitle", + "s", + # + "--combined", + "title", + "t", + ).score() + + m = score.meta.metatag + assert m.composer == "c" + assert m.lyricist == "l" + assert m.movement_title == "s" + assert m.work_title == "t" + + v = score.meta.vbox + assert v.composer == "c" + assert v.lyricist == "l" + assert v.subtitle == "s" + assert v.title == "t" class TestOptionSetField: