debian-koji-osbuild/test/unit/test_builder.py
Christian Kellner 9e98f10afc test/unit: extract common code
Create a new plugintest.PluginTest class that shares the plugin
loading code that is common to all plugin testing. Adapt the
existing (hub, builder) tests.
Also correct the name for test_builder.TestHubPlugin to
TestBuilderPlugin.
2020-09-14 13:06:52 +01:00

74 lines
2.2 KiB
Python

#
# koji hub plugin unit tests
#
import koji
from flexmock import flexmock
from plugintest import PluginTest
@PluginTest.load_plugin("builder")
class TestBuilderPlugin(PluginTest):
def test_unknown_build_target(self):
session = flexmock()
session.should_receive("getBuildTarget") \
.with_args("target", strict=True) \
.and_return(None)
options = flexmock(allowed_scms='pkg.osbuild.org:/*:no',
workdir="/tmp")
handler = self.plugin.OSBuildImage(1,
"osbuildImage",
"params",
session,
options)
args = ["name", "version", "distro",
["image_type"],
"target",
["arches"],
{}]
with self.assertRaises(koji.BuildError):
handler.handler(*args)
def test_unsupported_architecture(self):
session = flexmock()
build_target = {
"build_tag": "fedora-build",
"name": "fedora-candidate",
"dest_tag_name": "fedora-updates"
}
session.should_receive("getBuildTarget") \
.with_args("fedora-candidate", strict=True) \
.and_return(build_target) \
.once()
session.should_receive('getBuildConfig') \
.with_args(build_target["build_tag"]) \
.and_return({"arches": "x86_64"})
options = flexmock(allowed_scms='pkg.osbuild.org:/*:no',
workdir="/tmp")
handler = self.plugin.OSBuildImage(1,
"osbuildImage",
"params",
session,
options)
args = ["name", "version", "distro",
["image_type"],
"fedora-candidate",
["s390x"],
{}]
with self.assertRaises(koji.BuildError) as err:
handler.handler(*args)
self.assertTrue(str(err).startswith("Unsupported"))