示例#1
0
    def test_fail_without_koji(self):
        plugins_json = {
            'postbuild_plugins': [],
        }

        # remove koji from config
        reactor_config_map = yaml.safe_load(REACTOR_CONFIG_MAP)
        del reactor_config_map['koji']
        no_koji_config_map = yaml.dump(reactor_config_map)

        user_params = self.user_params
        mock_env = {
            'BUILD': '{}',
            'OUTPUT_IMAGE': 'asdf:fdsa',
            'OUTPUT_REGISTRY': 'localhost:5000',
            'REACTOR_CONFIG': no_koji_config_map,
            'USER_PARAMS': json.dumps(user_params),
        }

        enable_plugins_configuration(plugins_json)

        flexmock(os, environ=mock_env)

        plugin = OSv3SourceContainerInputPlugin()
        with pytest.raises(RuntimeError) as exc_info:
            plugin.run()

        assert 'require enabled koji integration' in str(exc_info.value)
示例#2
0
    def test_validate_reactor_config_override(self, override, valid):
        plugins_json = {
            'postbuild_plugins': [],
        }
        user_params = self.user_params
        if override:
            user_params['reactor_config_override'] = override
        mock_env = {
            'BUILD': '{}',
            'OUTPUT_IMAGE': 'asdf:fdsa',
            'OUTPUT_REGISTRY': 'localhost:5000',
            'REACTOR_CONFIG': REACTOR_CONFIG_MAP,
            'USER_PARAMS': json.dumps(user_params),
        }

        enable_plugins_configuration(plugins_json)

        flexmock(os, environ=mock_env)

        plugin = OSv3SourceContainerInputPlugin()
        if valid:
            plugin.run()
        else:
            with pytest.raises(ValidationError):
                plugin.run()
示例#3
0
    def test_sets_selflink(self, build, expected):
        mock_env = {
            'BUILD': build,
            'OUTPUT_IMAGE': 'asdf:fdsa',
            'OUTPUT_REGISTRY': 'localhost:5000',
            'REACTOR_CONFIG': REACTOR_CONFIG_MAP,
            'USER_PARAMS': json.dumps(self.user_params),
        }
        flexmock(os, environ=mock_env)

        plugin = OSv3SourceContainerInputPlugin()
        assert plugin.run()['openshift_build_selflink'] == expected
示例#4
0
    def test_doesnt_fail_if_no_plugins(self):
        mock_env = {
            'BUILD': '{}',
            'OUTPUT_IMAGE': 'asdf:fdsa',
            'OUTPUT_REGISTRY': 'localhost:5000',
            'ATOMIC_REACTOR_PLUGINS': '{}',
            'REACTOR_CONFIG': REACTOR_CONFIG_MAP,
            'USER_PARAMS': json.dumps(self.user_params),
        }
        flexmock(os, environ=mock_env)

        plugin = OSv3SourceContainerInputPlugin()
        assert plugin.run()['openshift_build_selflink'] is None
示例#5
0
    def test_arrangement_version(self, arrangement_version, valid):
        plugins_json = {
            'postbuild_plugins': [],
        }
        user_params = self.user_params
        user_params['arrangement_version'] = arrangement_version
        mock_env = {
            'BUILD': '{}',
            'OUTPUT_IMAGE': 'asdf:fdsa',
            'OUTPUT_REGISTRY': 'localhost:5000',
            'REACTOR_CONFIG': REACTOR_CONFIG_MAP,
            'USER_PARAMS': json.dumps(user_params),
        }

        enable_plugins_configuration(plugins_json)

        flexmock(os, environ=mock_env)

        plugin = OSv3SourceContainerInputPlugin()
        if valid:
            plugin.run()
        else:
            with pytest.raises(ValueError):
                plugin.run()
示例#6
0
 def test_is_autousable(self, mock_env, expected):
     flexmock(os, environ=mock_env)
     assert OSv3SourceContainerInputPlugin.is_autousable() == expected