From cf56696d90dac8370be878a4663d7f51b5799fc4 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 16 Sep 2020 14:37:17 +0200 Subject: [PATCH] test/builder: check stand-alone usage Check the basic usage of the plugin as a stand-alone client for the osbuild-composer API. --- test/unit/test_builder.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/unit/test_builder.py b/test/unit/test_builder.py index 817d72a..0916249 100644 --- a/test/unit/test_builder.py +++ b/test/unit/test_builder.py @@ -4,7 +4,9 @@ import json import os +import sys import uuid +import unittest.mock from flexmock import flexmock import koji @@ -260,3 +262,26 @@ class TestBuilderPlugin(PluginTest): res = handler.handler(*args) assert res, "invalid compose result" + + @httpretty.activate + def test_cli_compose_success(self): + # Check the basic usage of the plugin as a stand-alone client + # for the osbuild-composer API + url = self.plugin.DEFAULT_COMPOSER_URL + composer = MockComposer(url, architectures=["x86_64"]) + composer.httpretty_regsiter() + + args = [ + "plugins/builder/osbuild.py", + "compose", + "Fedora-Cloud-Image", + "32", + "20201015.0", + "fedora-32", + "http://download.localhost/pub/linux/$arch", + "x86_64" + ] + + with unittest.mock.patch.object(sys, 'argv', args): + res = self.plugin.main() + self.assertEqual(res, 0)