mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 05:04:38 +03:00
Allow ListCommand to choose tool by version
This adds the function `ListCommand.fetch_tool_by_simple_spec`. This allows the caller to specify a SimpleSpec and the name of a tool, and the function will return the Updates.xml record for the specified tool with the largest version number that satisfies the SimpleSpec. This is meant to allow users to install tools without specifying an explicit version number. This also adds some test code to validate the complicated parts of this code. This also extends `helper.xml_to_modules`, so that a caller can automatically get all tags in an XML element without explicitly specifying them.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import binascii
|
||||
import os
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
from requests.models import Response
|
||||
from semantic_version import Version
|
||||
|
||||
from aqt import helper
|
||||
|
||||
@@ -95,3 +97,16 @@ def test_helper_downloadBinary_sha256(tmp_path, monkeypatch):
|
||||
helper.downloadBinaryFile(
|
||||
"http://example.com/test.xml", out, "sha256", expected, 60
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"version, expect",
|
||||
[
|
||||
('1.33.1', Version('1.33.1')),
|
||||
('1.33.1-202102101246', Version('1.33.1-202102101246')),
|
||||
('1.33-202102101246', Version('1.33.0-202102101246')),
|
||||
('2020-05-19-1', Version('2020.0.0-05-19-1')),
|
||||
],
|
||||
)
|
||||
def test_helper_to_version_permissive(version, expect):
|
||||
assert helper.to_version_permissive(version) == expect
|
||||
|
||||
Reference in New Issue
Block a user