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)
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()
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
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
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()
def test_is_autousable(self, mock_env, expected): flexmock(os, environ=mock_env) assert OSv3SourceContainerInputPlugin.is_autousable() == expected