mirror of
https://github.com/resf/distro-tools.git
synced 2024-11-24 22:21:26 +00:00
Add run_apollo_tree function
This commit is contained in:
parent
aecc8c3823
commit
a686b921ae
@ -270,14 +270,40 @@ async def update_repomd_xml(repomd_xml_path: str, updateinfo: dict):
|
|||||||
os.remove(existing_updateinfo_path)
|
os.remove(existing_updateinfo_path)
|
||||||
|
|
||||||
|
|
||||||
async def main(args):
|
async def run_apollo_tree(
|
||||||
base_paths = await scan_path(
|
base_format: str,
|
||||||
args.path,
|
manual: bool,
|
||||||
args.base_format,
|
auto_scan: bool,
|
||||||
args.ignore,
|
path: str,
|
||||||
)
|
ignore: list,
|
||||||
print(args)
|
product_name: str,
|
||||||
pass
|
):
|
||||||
|
if manual:
|
||||||
|
raise Exception("Manual mode not implemented yet")
|
||||||
|
|
||||||
|
if auto_scan:
|
||||||
|
repos = await scan_path(
|
||||||
|
path,
|
||||||
|
base_format,
|
||||||
|
ignore,
|
||||||
|
)
|
||||||
|
|
||||||
|
for _, repo_variants in repos.items():
|
||||||
|
for repo in repo_variants:
|
||||||
|
updateinfo = await fetch_updateinfo_from_apollo(
|
||||||
|
repo,
|
||||||
|
product_name,
|
||||||
|
)
|
||||||
|
|
||||||
|
gzipped = await gzip_updateinfo(updateinfo)
|
||||||
|
await write_updateinfo_to_file(
|
||||||
|
repo["found_path"],
|
||||||
|
gzipped,
|
||||||
|
)
|
||||||
|
await update_repomd_xml(
|
||||||
|
repo["found_path"],
|
||||||
|
gzipped,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -343,4 +369,13 @@ if __name__ == "__main__":
|
|||||||
if p_args.auto_scan and not p_args.path:
|
if p_args.auto_scan and not p_args.path:
|
||||||
parser.error("Must specify path to scan for repos in auto-scan mode")
|
parser.error("Must specify path to scan for repos in auto-scan mode")
|
||||||
|
|
||||||
asyncio.run(main(p_args))
|
asyncio.run(
|
||||||
|
run_apollo_tree(
|
||||||
|
p_args.base_format,
|
||||||
|
p_args.manual,
|
||||||
|
p_args.auto_scan,
|
||||||
|
p_args.path,
|
||||||
|
p_args.ignore,
|
||||||
|
p_args.product_name,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@ -332,7 +332,6 @@ async def test_fetch_updateinfo_from_apollo_mock(mocker):
|
|||||||
updateinfo = await apollo_tree.fetch_updateinfo_from_apollo(
|
updateinfo = await apollo_tree.fetch_updateinfo_from_apollo(
|
||||||
repo,
|
repo,
|
||||||
"Rocky Linux 8 x86_64",
|
"Rocky Linux 8 x86_64",
|
||||||
True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert updateinfo == updateinfo_xml
|
assert updateinfo == updateinfo_xml
|
||||||
@ -363,7 +362,6 @@ async def test_gzip_updateinfo(mocker):
|
|||||||
updateinfo = await apollo_tree.fetch_updateinfo_from_apollo(
|
updateinfo = await apollo_tree.fetch_updateinfo_from_apollo(
|
||||||
repo,
|
repo,
|
||||||
"Rocky Linux 8 x86_64",
|
"Rocky Linux 8 x86_64",
|
||||||
True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert updateinfo == updateinfo_xml
|
assert updateinfo == updateinfo_xml
|
||||||
@ -399,7 +397,6 @@ async def test_write_updateinfo_to_file(mocker):
|
|||||||
updateinfo = await apollo_tree.fetch_updateinfo_from_apollo(
|
updateinfo = await apollo_tree.fetch_updateinfo_from_apollo(
|
||||||
repo,
|
repo,
|
||||||
"Rocky Linux 8 x86_64",
|
"Rocky Linux 8 x86_64",
|
||||||
True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert updateinfo == updateinfo_xml
|
assert updateinfo == updateinfo_xml
|
||||||
@ -452,7 +449,6 @@ async def test_update_repomd_xml(mocker):
|
|||||||
updateinfo = await apollo_tree.fetch_updateinfo_from_apollo(
|
updateinfo = await apollo_tree.fetch_updateinfo_from_apollo(
|
||||||
repo,
|
repo,
|
||||||
"Rocky Linux 8 x86_64",
|
"Rocky Linux 8 x86_64",
|
||||||
True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert updateinfo == updateinfo_xml
|
assert updateinfo == updateinfo_xml
|
||||||
@ -496,3 +492,51 @@ async def test_update_repomd_xml(mocker):
|
|||||||
actual_repomd_xml = f.read()
|
actual_repomd_xml = f.read()
|
||||||
|
|
||||||
assert actual_repomd_xml == expected_repomd_xml
|
assert actual_repomd_xml == expected_repomd_xml
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_run_apollo_tree(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 x86_64",
|
||||||
|
)
|
||||||
|
|
||||||
|
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