diff --git a/osbuild/testutil/__init__.py b/osbuild/testutil/__init__.py index 322944de..0681ff9b 100644 --- a/osbuild/testutil/__init__.py +++ b/osbuild/testutil/__init__.py @@ -183,3 +183,21 @@ def find_one_subclass_in_module(module: ModuleType, subclass: Type) -> object: raise ValueError(f"already have {cls}, also found {name}:{memb}") cls = memb return cls + + +def make_fake_images_inputs(fake_oci_path, name): + fname = fake_oci_path.name + dirname = fake_oci_path.parent + return { + "images": { + "path": dirname, + "data": { + "archives": { + fname: { + "format": "oci-archive", + "name": name, + }, + }, + }, + }, + } diff --git a/stages/test/test_bootc_install_to_fs.py b/stages/test/test_bootc_install_to_fs.py index f31dc03e..7f1fe9a0 100644 --- a/stages/test/test_bootc_install_to_fs.py +++ b/stages/test/test_bootc_install_to_fs.py @@ -31,7 +31,7 @@ FAKE_INPUTS = { "path": "/input/images/path", "data": { "archives": { - "/input/images/path": { + "filename": { "format": "oci-archive", "name": "some-img-name", }, @@ -69,7 +69,7 @@ def test_bootc_install_to_fs(mock_run, mocked_named_tmp, mocked_temp_dir, stage_ "path": "/input/images/path", "data": { "archives": { - "/input/images/path": { + "filename": { "format": "oci-archive", "name": "some-img-name", }, diff --git a/stages/test/test_container_deploy.py b/stages/test/test_container_deploy.py index 02a11795..748369af 100644 --- a/stages/test/test_container_deploy.py +++ b/stages/test/test_container_deploy.py @@ -9,7 +9,7 @@ from unittest.mock import call, patch import pytest import osbuild.testutil -from osbuild.testutil import has_executable, make_container +from osbuild.testutil import has_executable, make_container, make_fake_images_inputs STAGE_NAME = "org.osbuild.container-deploy" @@ -22,28 +22,15 @@ def test_container_deploy_integration(tmp_path, stage_module): with make_container(tmp_path, {"file1": "file1 from base"}) as base_tag: with make_container(tmp_path, {"file1": "file1 from final layer"}, base_tag) as cont_tag: # export for the container-deploy stage - fake_container_dst = tmp_path / "fake-container" + fake_oci_path = tmp_path / "fake-container" subprocess.check_call([ "podman", "save", "--format=oci-archive", - f"--output={fake_container_dst}", + f"--output={fake_oci_path}", cont_tag, ]) - inputs = { - "images": { - # seems to be unused with fake_container_path? - "path": fake_container_dst, - "data": { - "archives": { - fake_container_dst: { - "format": "oci-archive", - "name": cont_tag, - }, - }, - }, - }, - } + inputs = make_fake_images_inputs(fake_oci_path, "some-name") output_dir = tmp_path / "output" options = {} @@ -66,28 +53,15 @@ def test_container_deploy_exclude(tmp_path, stage_module): "dir2/file4": "dir2/file4 content", }) as base_tag: # export for the container-deploy stage - fake_container_dst = tmp_path / "fake-container" + fake_oci_path = tmp_path / "fake-container" subprocess.check_call([ "podman", "save", "--format=oci-archive", - f"--output={fake_container_dst}", + f"--output={fake_oci_path}", base_tag, ]) - inputs = { - "images": { - # seems to be unused with fake_container_path? - "path": fake_container_dst, - "data": { - "archives": { - fake_container_dst: { - "format": "oci-archive", - "name": base_tag, - }, - }, - }, - }, - } + inputs = make_fake_images_inputs(fake_oci_path, "some-name") options = { "exclude": [ "file2", diff --git a/stages/test/test_skopeo.py b/stages/test/test_skopeo.py index e6a975e4..119e9ad4 100644 --- a/stages/test/test_skopeo.py +++ b/stages/test/test_skopeo.py @@ -7,7 +7,7 @@ import tarfile import pytest from osbuild import testutil -from osbuild.testutil import has_executable, make_container +from osbuild.testutil import has_executable, make_container, make_fake_images_inputs STAGE_NAME = "org.osbuild.skopeo" @@ -60,23 +60,6 @@ def make_fake_oci_archive(tmp_path): return fake_container_dst -def make_skopeo_copy_inputs(fake_oci_path, name): - return { - "images": { - # seems to be unused with fake_container_path? - "path": fake_oci_path, - "data": { - "archives": { - fake_oci_path: { - "format": "oci-archive", - "name": name, - }, - }, - }, - }, - } - - def assert_manifest_file(manifest_file): assert manifest_file.exists() data = json.loads(manifest_file.read_bytes()) @@ -88,7 +71,7 @@ def assert_manifest_file(manifest_file): def _test_skopeo_copy(tmp_path, stage_module, typ, dest_name): fake_oci_path = make_fake_oci_archive(tmp_path) - inputs = make_skopeo_copy_inputs(fake_oci_path, "some-name") + inputs = make_fake_images_inputs(fake_oci_path, "some-name") output_dir = tmp_path / "output" local_path = f"/some/{dest_name}"