fail on mismatched tool versions

This recreates the legacy behavior, where `aqt tool` would fail to
install a tool variant when the version in the xml file does not match
the version requested in cli arguments.

This also recreates a bug where `aqt tool` cannot install tools that
do not have a valid semantic version.
This commit is contained in:
David Dalcino
2021-09-30 19:15:32 -07:00
parent 4d1b09287e
commit c5b89f6170
4 changed files with 39 additions and 16 deletions

View File

@@ -253,22 +253,8 @@ def test_cli_legacy_tool_new_syntax(monkeypatch, capsys, cmd):
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"
f"Specified target combination is not valid: {command[1]} {command[2]} {command[4]}\n"
f"Failed to locate XML data for the tool '{command[2]}'.\n"
"==============================Suggested follow-up:==============================\n"
"* Please use 'aqt list-tool windows desktop' to show tools available.\n"
"Invalid version: 'tools_ifw'! Please use the form '5.X.Y'.\n"
)
arch = "x86" if command[1] == "windows" else "x64"
expect_url_end = f"{command[1]}_{arch}/desktop/{command[2]}/Updates.xml"
def mock_get(url: str, *args):
assert url.endswith(expect_url_end), "Failure means test is setup wrong"
# command[2] is a tool that doesn't exist, so:
raise ArchiveDownloadError(
f"Failed to retrieve file at {url}\n" f"Server response code: 404, reason: tool {command[2]} does not exist"
)
monkeypatch.setattr("aqt.archives.getUrl", mock_get)
cli = Cli()
cli._setup_settings()