mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 05:04:38 +03:00
fix: support new ifw repository pass
-Add tests for ToolArchives repo folder resolution -Refactor repository path handling -Add condition to detect ifw47 or later versions to switch archive repository path Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
@@ -752,6 +752,12 @@ class ToolArchives(QtArchives):
|
||||
update_xmls = [UpdateXmls(os_target_folder, update_xml_text)]
|
||||
self._parse_update_xmls(update_xmls, None)
|
||||
|
||||
def _main_repo_folder(self, os_segment: str, name: str) -> str:
|
||||
"""Build the main repository folder path for Updates.xml."""
|
||||
if name == "tools_ifw" and self.tool_version_str != "tools_ifw47":
|
||||
return posixpath.join("online/qtsdkrepository", os_segment, "ifw", self.tool_version_str)
|
||||
return posixpath.join("online/qtsdkrepository", os_segment, self.target, name)
|
||||
|
||||
def _parse_update_xml(self, os_target_folder: str, update_xml_text: str, *ignored: Any) -> None:
|
||||
update_xml = Updates.fromstring(self.base, update_xml_text)
|
||||
self._append_tool_update(os_target_folder, update_xml, self.arch, self.tool_version_str)
|
||||
|
||||
66
tests/test_tools_archives.py
Normal file
66
tests/test_tools_archives.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from aqt.archives import ToolArchives
|
||||
from aqt.helper import Settings
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_settings():
|
||||
Settings.load_settings(os.path.join(os.path.dirname(__file__), "data", "settings.ini"))
|
||||
|
||||
|
||||
def _stub_download_xml(self, *args, **kwargs):
|
||||
# Minimal valid Updates XML content; parsing is bypassed in these tests
|
||||
# because we monkeypatch _parse_update_xml.
|
||||
return "<Updates></Updates>"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"os_name,target,tool_name,tool_version,expected_path",
|
||||
[
|
||||
(
|
||||
"linux",
|
||||
"desktop",
|
||||
"tools_ninja",
|
||||
None,
|
||||
"online/qtsdkrepository/linux_x64/desktop/tools_ninja",
|
||||
),
|
||||
(
|
||||
"linux",
|
||||
"desktop",
|
||||
"tools_ifw",
|
||||
"tools_ifw410",
|
||||
"online/qtsdkrepository/linux_x64/ifw/tools_ifw410",
|
||||
),
|
||||
(
|
||||
"linux",
|
||||
"desktop",
|
||||
"tools_ifw",
|
||||
"tools_ifw47",
|
||||
"online/qtsdkrepository/linux_x64/desktop/tools_ifw",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_tool_archives_repo_folder(monkeypatch, os_name, target, tool_name, tool_version, expected_path):
|
||||
# Capture the target folder passed to _parse_update_xml
|
||||
captured = {}
|
||||
|
||||
def _capture_parse(self, os_target_folder, update_xml_text, *ignored):
|
||||
captured["folder"] = os_target_folder
|
||||
# Do nothing else; skip actual parsing for this test.
|
||||
return None
|
||||
|
||||
# Avoid any network/file IO and ensure our capture is invoked
|
||||
monkeypatch.setattr(ToolArchives, "_download_update_xml", _stub_download_xml)
|
||||
monkeypatch.setattr(ToolArchives, "_parse_update_xml", _capture_parse)
|
||||
|
||||
# Create the ToolArchives instance; __init__ triggers _get_archives()
|
||||
ToolArchives(os_name=os_name, target=target, tool_name=tool_name, base=Settings.baseurl, version_str=tool_version)
|
||||
|
||||
assert captured["folder"] == expected_path
|
||||
|
||||
# And that, when combined with base, it forms the expected URL root
|
||||
expected_url = f"{Settings.baseurl}/{expected_path}"
|
||||
assert expected_url.startswith("http")
|
||||
Reference in New Issue
Block a user