Skip to content

Commit

Permalink
refactor: remove legacy command tests
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Sep 29, 2024
1 parent 2615219 commit 27e206c
Showing 1 changed file with 0 additions and 68 deletions.
68 changes: 0 additions & 68 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,52 +234,6 @@ def test_cli_input_errors(capsys, cmd, expect_msg, should_show_help):
assert err.rstrip().endswith(expect_msg)


# These commands use the new syntax with the legacy commands
@pytest.mark.parametrize(
"cmd",
(
"install linux desktop 5.10.0",
"install linux desktop 5.10.0 gcc_64",
"src linux desktop 5.10.0",
"doc linux desktop 5.10.0",
"example linux desktop 5.10.0",
"tool windows desktop tools_ifw",
),
)
def test_cli_legacy_commands_with_wrong_syntax(cmd):
cli = Cli()
cli._setup_settings()
with pytest.raises(SystemExit) as e:
cli.run(cmd.split())
assert e.type == SystemExit


@pytest.mark.parametrize(
"cmd",
(
"tool windows desktop tools_ifw qt.tools.ifw.31", # New syntax
"tool windows desktop tools_ifw 1.2.3",
),
)
def test_cli_legacy_tool_new_syntax(monkeypatch, capsys, cmd):
# These incorrect commands cannot be filtered out directly by argparse because
# they have the correct number of arguments.
command = cmd.split()

expected = (
"WARNING : The command 'tool' is deprecated and marked for removal in a future version of aqt.\n"
"In the future, please use the command 'install-tool' instead.\n"
"ERROR : Invalid version: 'tools_ifw'! Please use the form '5.X.Y'.\n"
)

cli = Cli()
cli._setup_settings()
assert 1 == cli.run(command)
out, err = capsys.readouterr()
actual = err[err.index("\n") + 1 :]
assert actual == expected


@pytest.mark.parametrize(
"cmd, expect_err",
(
Expand Down Expand Up @@ -308,28 +262,6 @@ def test_cli_list_qt_deprecated_flags(capsys, cmd: str, expect_err: str):
assert err == expect_err


# These commands come directly from examples in the legacy documentation
@pytest.mark.parametrize(
"cmd",
(
"install 5.10.0 linux desktop", # default arch
"install 5.10.2 linux android android_armv7",
"src 5.15.2 windows desktop --archives qtbase --kde",
"doc 5.15.2 windows desktop -m qtcharts qtnetworkauth",
"examples 5.15.2 windows desktop -m qtcharts qtnetworkauth",
"tool linux tools_ifw 4.0 qt.tools.ifw.40",
),
)
def test_cli_legacy_commands_with_correct_syntax(monkeypatch, cmd):
# Pretend to install correctly when any command is run
for func in ("run_install_qt", "run_install_src", "run_install_doc", "run_install_example", "run_install_tool"):
monkeypatch.setattr(Cli, func, lambda *args, **kwargs: 0)

cli = Cli()
cli._setup_settings()
assert 0 == cli.run(cmd.split())


def test_cli_unexpected_error(monkeypatch, capsys):
def _mocked_run(*args):
raise RuntimeError("Some unexpected error")
Expand Down

0 comments on commit 27e206c

Please sign in to comment.