mirror of
https://github.com/resf/distro-tools.git
synced 2024-11-24 22:21:26 +00:00
Support $arch in product name
This commit is contained in:
parent
a686b921ae
commit
e1f2e757bf
@ -126,14 +126,13 @@ async def scan_path(
|
||||
async def fetch_updateinfo_from_apollo(
|
||||
repo: dict,
|
||||
product_name: str,
|
||||
arch: str = None,
|
||||
api_base: str = None,
|
||||
) -> str:
|
||||
pname_arch = product_name.replace("$arch", repo["arch"])
|
||||
if not api_base:
|
||||
api_base = "https://apollo.build.resf.org/api/v3/updateinfo"
|
||||
api_url = f"{api_base}/{quote(product_name)}/{quote(repo['name'])}/updateinfo.xml"
|
||||
if arch:
|
||||
api_url += f"?req_arch={arch}"
|
||||
api_url = f"{api_base}/{quote(pname_arch)}/{quote(repo['name'])}/updateinfo.xml"
|
||||
api_url += f"?req_arch={repo['arch']}"
|
||||
|
||||
logger.info("Fetching updateinfo from %s", api_url)
|
||||
async with aiohttp.ClientSession() as session:
|
||||
|
@ -540,3 +540,51 @@ async def test_run_apollo_tree(mocker):
|
||||
actual_repomd_xml = f.read()
|
||||
|
||||
assert actual_repomd_xml == expected_repomd_xml
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_run_apollo_tree_arch_in_product(mocker):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
repos = await _setup_test_baseos(directory)
|
||||
|
||||
# Read data/updateinfo__test__1.xml
|
||||
with open(
|
||||
path.join(
|
||||
path.dirname(__file__), "data", "updateinfo__test__1.xml"
|
||||
),
|
||||
"r",
|
||||
encoding="utf-8",
|
||||
) as f:
|
||||
updateinfo_xml = f.read()
|
||||
|
||||
resp = MockResponse(updateinfo_xml, 200)
|
||||
mocker.patch("aiohttp.ClientSession.get", return_value=resp)
|
||||
|
||||
mocker.patch("time.time", return_value=1674284973)
|
||||
await apollo_tree.run_apollo_tree(
|
||||
"$reponame/$arch/os/repodata/repomd.xml",
|
||||
False,
|
||||
True,
|
||||
directory,
|
||||
[],
|
||||
"Rocky Linux 8 $arch",
|
||||
)
|
||||
|
||||
for _, repo_variants in repos.items():
|
||||
for repo in repo_variants:
|
||||
# Check that the repomd.xml file matches baseos__base__repomd__x86_64_with_updateinfo.xml from data
|
||||
with open(
|
||||
path.join(
|
||||
path.dirname(__file__),
|
||||
"data",
|
||||
"baseos__base__repomd__x86_64_with_updateinfo.xml",
|
||||
),
|
||||
"r",
|
||||
encoding="utf-8",
|
||||
) as f:
|
||||
expected_repomd_xml = f.read()
|
||||
|
||||
with open(repo["found_path"], "r", encoding="utf-8") as f:
|
||||
actual_repomd_xml = f.read()
|
||||
|
||||
assert actual_repomd_xml == expected_repomd_xml
|
||||
|
Loading…
Reference in New Issue
Block a user