From e1edb12d115293b22610b9deead8647e017971cf Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 15 Sep 2020 18:05:27 +0200 Subject: [PATCH] test/builder: check a successful compose Use the standard session and options mock object together with the new composer mock object to simulate a successful compose: the mock composer will accept the request and also status calls for it, which will immediately return with success. The plugin should then return and indicate a successful compose. --- test/unit/test_builder.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/unit/test_builder.py b/test/unit/test_builder.py index 54457e6..e033823 100644 --- a/test/unit/test_builder.py +++ b/test/unit/test_builder.py @@ -234,3 +234,26 @@ class TestBuilderPlugin(PluginTest): with self.assertRaises(koji.GenericError): handler.handler(*args) + @httpretty.activate + def test_compose_success(self): + # Simulate a successful compose, check return value + session = self.mock_session() + options = self.mock_options() + + handler = self.plugin.OSBuildImage(1, + "osbuildImage", + "params", + session, + options) + + args = ["name", "version", "distro", + ["image_type"], + "fedora-candidate", + ["x86_64"], + {}] + + composer = MockComposer(architectures=["x86_64"]) + composer.httpretty_regsiter() + + res = handler.handler(*args) + assert res, "invalid compose result"