Fix config validation for osbuild
Tests are now added for it as well. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
4c88e7dc0e
commit
27bab19a5e
@ -1141,16 +1141,16 @@ def make_schema():
|
|||||||
"version": {"type": "string"},
|
"version": {"type": "string"},
|
||||||
"distro": {"type": "string"},
|
"distro": {"type": "string"},
|
||||||
"target": {"type": "string"},
|
"target": {"type": "string"},
|
||||||
"image_type": {"$ref": "#/definitions/strings"},
|
"image_types": {"$ref": "#/definitions/strings"},
|
||||||
"arches": {"$ref": "#/definitions/list_of_strings"},
|
"arches": {"$ref": "#/definitions/list_of_strings"},
|
||||||
"release": {"type": "string"},
|
"release": {"type": "string"},
|
||||||
"repo": {"$ref": "#/definitions/list_of_strings"},
|
"repo": {"$ref": "#/definitions/list_of_strings"},
|
||||||
"failable": {"$ref": "#/definitions/list_of_strings"},
|
"failable": {"$ref": "#/definitions/list_of_strings"},
|
||||||
|
"subvariant": {"type": "string"},
|
||||||
},
|
},
|
||||||
"subvariant": {"type": "string"},
|
"required": ["name", "distro", "image_types"],
|
||||||
|
"additionalProperties": False,
|
||||||
},
|
},
|
||||||
"required": ["name", "distro", "image_type"],
|
|
||||||
"additionalProperties": False,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -15,15 +15,19 @@ class OSBuildPhaseTest(helpers.PungiTestCase):
|
|||||||
def test_run(self, ThreadPool):
|
def test_run(self, ThreadPool):
|
||||||
cfg = {
|
cfg = {
|
||||||
"name": "test-image",
|
"name": "test-image",
|
||||||
|
"distro": "rhel-8",
|
||||||
"version": "1",
|
"version": "1",
|
||||||
"target": "image-target",
|
"target": "image-target",
|
||||||
"arches": ["x86_64"],
|
"arches": ["x86_64"],
|
||||||
"failable": ["x86_64"],
|
"failable": ["x86_64"],
|
||||||
|
"image_types": ["qcow2"],
|
||||||
}
|
}
|
||||||
compose = helpers.DummyCompose(
|
compose = helpers.DummyCompose(
|
||||||
self.topdir, {"osbuild": {"^Everything$": [cfg]}}
|
self.topdir, {"osbuild": {"^Everything$": [cfg]}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.assertValidConfig(compose.conf)
|
||||||
|
|
||||||
pool = ThreadPool.return_value
|
pool = ThreadPool.return_value
|
||||||
|
|
||||||
phase = osbuild.OSBuildPhase(compose)
|
phase = osbuild.OSBuildPhase(compose)
|
||||||
@ -51,7 +55,11 @@ class OSBuildPhaseTest(helpers.PungiTestCase):
|
|||||||
|
|
||||||
@mock.patch("pungi.phases.osbuild.ThreadPool")
|
@mock.patch("pungi.phases.osbuild.ThreadPool")
|
||||||
def test_run_with_global_options(self, ThreadPool):
|
def test_run_with_global_options(self, ThreadPool):
|
||||||
cfg = {"name": "test-image"}
|
cfg = {
|
||||||
|
"name": "test-image",
|
||||||
|
"distro": "rhel-8",
|
||||||
|
"image_types": ["qcow2"],
|
||||||
|
}
|
||||||
compose = helpers.DummyCompose(
|
compose = helpers.DummyCompose(
|
||||||
self.topdir,
|
self.topdir,
|
||||||
{
|
{
|
||||||
@ -62,6 +70,8 @@ class OSBuildPhaseTest(helpers.PungiTestCase):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.assertValidConfig(compose.conf)
|
||||||
|
|
||||||
pool = ThreadPool.return_value
|
pool = ThreadPool.return_value
|
||||||
|
|
||||||
phase = osbuild.OSBuildPhase(compose)
|
phase = osbuild.OSBuildPhase(compose)
|
||||||
@ -122,7 +132,7 @@ class RunOSBuildThreadTest(helpers.PungiTestCase):
|
|||||||
@mock.patch("pungi.phases.osbuild.Linker")
|
@mock.patch("pungi.phases.osbuild.Linker")
|
||||||
@mock.patch("pungi.phases.osbuild.kojiwrapper.KojiWrapper")
|
@mock.patch("pungi.phases.osbuild.kojiwrapper.KojiWrapper")
|
||||||
def test_process(self, KojiWrapper, Linker):
|
def test_process(self, KojiWrapper, Linker):
|
||||||
cfg = {"name": "test-image", "distro": "rhel8", "image_types": ["qcow2"]}
|
cfg = {"name": "test-image", "distro": "rhel-8", "image_types": ["qcow2"]}
|
||||||
koji = KojiWrapper.return_value
|
koji = KojiWrapper.return_value
|
||||||
koji.watch_task.side_effect = self.make_fake_watch(0)
|
koji.watch_task.side_effect = self.make_fake_watch(0)
|
||||||
koji.koji_proxy.osbuildImage.return_value = 1234
|
koji.koji_proxy.osbuildImage.return_value = 1234
|
||||||
@ -171,7 +181,7 @@ class RunOSBuildThreadTest(helpers.PungiTestCase):
|
|||||||
mock.call.koji_proxy.osbuildImage(
|
mock.call.koji_proxy.osbuildImage(
|
||||||
"test-image",
|
"test-image",
|
||||||
"1",
|
"1",
|
||||||
"rhel8",
|
"rhel-8",
|
||||||
["qcow2"],
|
["qcow2"],
|
||||||
"image-target",
|
"image-target",
|
||||||
["aarch64", "x86_64"],
|
["aarch64", "x86_64"],
|
||||||
@ -232,7 +242,7 @@ class RunOSBuildThreadTest(helpers.PungiTestCase):
|
|||||||
|
|
||||||
@mock.patch("pungi.phases.osbuild.kojiwrapper.KojiWrapper")
|
@mock.patch("pungi.phases.osbuild.kojiwrapper.KojiWrapper")
|
||||||
def test_task_fails(self, KojiWrapper):
|
def test_task_fails(self, KojiWrapper):
|
||||||
cfg = {"name": "test-image", "distro": "rhel8", "image_types": ["qcow2"]}
|
cfg = {"name": "test-image", "distro": "rhel-8", "image_types": ["qcow2"]}
|
||||||
koji = KojiWrapper.return_value
|
koji = KojiWrapper.return_value
|
||||||
koji.watch_task.side_effect = self.make_fake_watch(1)
|
koji.watch_task.side_effect = self.make_fake_watch(1)
|
||||||
koji.koji_proxy.osbuildImage.return_value = 1234
|
koji.koji_proxy.osbuildImage.return_value = 1234
|
||||||
@ -257,7 +267,7 @@ class RunOSBuildThreadTest(helpers.PungiTestCase):
|
|||||||
def test_task_fails_but_is_failable(self, KojiWrapper):
|
def test_task_fails_but_is_failable(self, KojiWrapper):
|
||||||
cfg = {
|
cfg = {
|
||||||
"name": "test-image",
|
"name": "test-image",
|
||||||
"distro": "rhel8",
|
"distro": "rhel-8",
|
||||||
"image_types": ["qcow2"],
|
"image_types": ["qcow2"],
|
||||||
"failable": ["x86_65"],
|
"failable": ["x86_65"],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user