def test_delete_single_view(self, delete_view_mock): """ Test handling the deletion of a single Jenkins view. """ args = self.parser.parse_args(['delete', '--view', 'test_view']) cmd.execute(args, self.config) # passes if executed without error
def test_delete_multiple_jobs(self, delete_job_mock): """ Test handling the deletion of multiple Jenkins jobs. """ args = self.parser.parse_args(['delete', 'test_job1', 'test_job2']) cmd.execute(args, self.config) # passes if executed without error
def test_recursive_multi_path(self, os_walk_mock, isdir_mock, update_job_mock): """ Run test mode and pass multiple paths with recursive path option. """ os_walk_mock.side_effect = os_walk_side_effects isdir_mock.return_value = True path_list = os_walk_return_values.keys() paths = [] for path in path_list: paths.extend([p for p, _ in os_walk_return_values[path]]) multipath = os.pathsep.join(path_list) args = self.parser.parse_args(['test', '-r', multipath]) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) update_job_mock.assert_called_with(paths, [], output=args.output_dir) args = self.parser.parse_args(['test', multipath]) self.config.set('job_builder', 'recursive', 'True') cmd.execute(args, self.config) update_job_mock.assert_called_with(paths, [], output=args.output_dir)
def test_recursive_path_option(self, os_walk_mock, isdir_mock, update_job_mock): """ Test handling of recursive path option """ os_walk_mock.return_value = [ ('/jjb_configs', ('dir1', 'dir2', 'dir3'), ()), ('/jjb_configs/dir1', ('bar',), ()), ('/jjb_configs/dir2', ('baz',), ()), ('/jjb_configs/dir3', (), ()), ('/jjb_configs/dir1/bar', (), ()), ('/jjb_configs/dir2/baz', (), ()), ] isdir_mock.return_value = True paths = [path for path, _, _ in os_walk_mock.return_value] args = self.parser.parse_args(['test', '-r', '/jjb_configs']) args.output_dir = mock.MagicMock() config = ConfigParser.ConfigParser() config.readfp(cStringIO.StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) # probably better to fail here update_job_mock.assert_called_with(paths, [], output=args.output_dir) args = self.parser.parse_args(['test', '/jjb_configs']) config.set('job_builder', 'recursive', 'True') cmd.execute(args, config) # probably better to fail here update_job_mock.assert_called_with(paths, [], output=args.output_dir)
def test_valid_job(self): """ Run test mode and pass a valid job name """ args = self.parser.parse_args(["test", os.path.join(self.fixtures_path, "cmd-001.yaml"), "foo-job"]) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) # probably better to fail here
def test_recursive_multi_path(self, os_walk_mock, isdir_mock, update_jobs_mock): """ Run test mode and pass multiple paths with recursive path option. """ os_walk_mock.side_effect = os_walk_side_effects isdir_mock.return_value = True path_list = os_walk_return_values.keys() paths = [] for path in path_list: paths.extend([p for p, _ in os_walk_return_values[path]]) multipath = os.pathsep.join(path_list) args = self.parser.parse_args(['test', '-r', multipath]) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) update_jobs_mock.assert_called_with(paths, [], output=args.output_dir, n_workers=mock.ANY) args = self.parser.parse_args(['test', multipath]) args.output_dir = mock.MagicMock() self.config.set('job_builder', 'recursive', 'True') cmd.execute(args, self.config) update_jobs_mock.assert_called_with(paths, [], output=args.output_dir, n_workers=mock.ANY)
def test_recursive_multi_path_with_excludes(self, os_walk_mock, isdir_mock, update_jobs_mock): """ Run test mode and pass multiple paths with recursive path option. """ os_walk_mock.side_effect = os_walk_side_effects isdir_mock.return_value = True path_list = os_walk_return_values.keys() paths = [] for path in path_list: paths.extend([p for p, __ in os_walk_return_values[path] if 'dir1' not in p and 'dir2' not in p]) multipath = os.pathsep.join(path_list) args = self.parser.parse_args(['test', '-r', multipath, '-x', 'dir1:dir2']) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) update_jobs_mock.assert_called_with(paths, [], output=args.output_dir, n_workers=mock.ANY)
def test_recursive_multi_path_with_excludes(self, os_walk_mock, isdir_mock, update_job_mock): """ Run test mode and pass multiple paths with recursive path option. """ os_walk_mock.side_effect = os_walk_side_effects isdir_mock.return_value = True path_list = os_walk_return_values.keys() paths = [] for path in path_list: paths.extend([ p for p, __ in os_walk_return_values[path] if 'dir1' not in p and 'dir2' not in p ]) multipath = os.pathsep.join(path_list) args = self.parser.parse_args( ['test', '-r', multipath, '-x', 'dir1:dir2']) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) update_job_mock.assert_called_with(paths, [], output=args.output_dir)
def test_delete_multiple_jobs(self, delete_job_mock): """ Test handling the deletion of multiple Jenkins jobs. """ args = self.parser.parse_args(['delete', 'test_job1', 'test_job2']) cmd.execute(args, self.config) # passes if executed without error
def test_delete_single_view(self, delete_view_mock): """ Test handling the deletion of a single Jenkins view. """ args = self.parser.parse_args(['delete', '--view', 'test_view']) cmd.execute(args, self.config) # passes if executed without error
def test_recursive_multi_path(self, os_walk_mock, isdir_mock, update_job_mock): """ Run test mode and pass multiple paths with recursive path option. """ os_walk_return_values = { '/jjb_projects': [ ('/jjb_projects', ('dir1', 'dir2', 'dir3'), ()), ('/jjb_projects/dir1', ('bar', ), ()), ('/jjb_projects/dir2', ('baz', ), ()), ('/jjb_projects/dir3', (), ()), ('/jjb_projects/dir1/bar', (), ()), ('/jjb_projects/dir2/baz', (), ()), ], '/jjb_templates': [ ('/jjb_templates', ('dir1', 'dir2', 'dir3'), ()), ('/jjb_templates/dir1', ('bar', ), ()), ('/jjb_templates/dir2', ('baz', ), ()), ('/jjb_templates/dir3', (), ()), ('/jjb_templates/dir1/bar', (), ()), ('/jjb_templates/dir2/baz', (), ()), ], '/jjb_macros': [ ('/jjb_macros', ('dir1', 'dir2', 'dir3'), ()), ('/jjb_macros/dir1', ('bar', ), ()), ('/jjb_macros/dir2', ('baz', ), ()), ('/jjb_macros/dir3', (), ()), ('/jjb_macros/dir1/bar', (), ()), ('/jjb_macros/dir2/baz', (), ()), ], } def os_walk_side_effects(path_name, topdown): return os_walk_return_values[path_name] os_walk_mock.side_effect = os_walk_side_effects isdir_mock.return_value = True path_list = os_walk_return_values.keys() paths = [] for path in path_list: paths.extend([p for p, _, _ in os_walk_return_values[path]]) multipath = os.pathsep.join(path_list) args = self.parser.parse_args(['test', '-r', multipath]) args.output_dir = mock.MagicMock() config = configparser.ConfigParser() config.readfp(StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) update_job_mock.assert_called_with(paths, [], output=args.output_dir) args = self.parser.parse_args(['test', multipath]) config.set('job_builder', 'recursive', 'True') cmd.execute(args, config) update_job_mock.assert_called_with(paths, [], output=args.output_dir)
def test_update_jobs_and_delete_old(self, builder_mock, delete_job_mock, get_jobs_mock, is_job_mock): """ Test update behaviour with --delete-old option Test update of jobs with the --delete-old option enabled, where only some jobs result in has_changed() to limit the number of times update_job is called, and have the get_jobs() method return additional jobs not in the input yaml to test that the code in cmd will call delete_job() after update_job() when '--delete-old' is set but only for the extra jobs. """ # set up some test data jobs = ['old_job001', 'old_job002'] extra_jobs = [{'name': name} for name in jobs] builder_obj = builder.Builder('http://jenkins.example.com', 'doesnot', 'matter', plugins_list={}) # get the instance created by mock and redirect some of the method # mocks to call real methods on a the above test object. b_inst = builder_mock.return_value b_inst.plugins_list = builder_obj.plugins_list b_inst.update_job.side_effect = builder_obj.update_job b_inst.delete_old_managed.side_effect = builder_obj.delete_old_managed def _get_jobs(): return builder_obj.parser.jobs + extra_jobs get_jobs_mock.side_effect = _get_jobs # override cache to ensure Jenkins.update_job called a limited number # of times self.cache_mock.return_value.has_changed.side_effect = ([True] * 2 + [False] * 2) path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', '--delete-old', path]) with mock.patch('jenkins_jobs.builder.Jenkins.update_job') as update: with mock.patch('jenkins_jobs.builder.Jenkins.is_managed', return_value=True): cmd.execute(args, self.config) self.assertEquals( 2, update.call_count, "Expected Jenkins.update_job to be called '%d' " "times, got '%d' calls instead.\n" "Called with: %s" % (2, update.call_count, update.mock_calls)) calls = [mock.call(name) for name in jobs] self.assertEquals( 2, delete_job_mock.call_count, "Expected Jenkins.delete_job to be called '%d' " "times got '%d' calls instead.\n" "Called with: %s" % (2, delete_job_mock.call_count, delete_job_mock.mock_calls)) delete_job_mock.assert_has_calls(calls, any_order=True)
def test_recursive_multi_path(self, os_walk_mock, isdir_mock, update_job_mock): """ Run test mode and pass multiple paths with recursive path option. """ os_walk_return_values = { '/jjb_projects': [ ('/jjb_projects', ('dir1', 'dir2', 'dir3'), ()), ('/jjb_projects/dir1', ('bar',), ()), ('/jjb_projects/dir2', ('baz',), ()), ('/jjb_projects/dir3', (), ()), ('/jjb_projects/dir1/bar', (), ()), ('/jjb_projects/dir2/baz', (), ()), ], '/jjb_templates': [ ('/jjb_templates', ('dir1', 'dir2', 'dir3'), ()), ('/jjb_templates/dir1', ('bar',), ()), ('/jjb_templates/dir2', ('baz',), ()), ('/jjb_templates/dir3', (), ()), ('/jjb_templates/dir1/bar', (), ()), ('/jjb_templates/dir2/baz', (), ()), ], '/jjb_macros': [ ('/jjb_macros', ('dir1', 'dir2', 'dir3'), ()), ('/jjb_macros/dir1', ('bar',), ()), ('/jjb_macros/dir2', ('baz',), ()), ('/jjb_macros/dir3', (), ()), ('/jjb_macros/dir1/bar', (), ()), ('/jjb_macros/dir2/baz', (), ()), ], } def os_walk_side_effects(path_name, topdown): return os_walk_return_values[path_name] os_walk_mock.side_effect = os_walk_side_effects isdir_mock.return_value = True path_list = os_walk_return_values.keys() paths = [] for path in path_list: paths.extend([p for p, _, _ in os_walk_return_values[path]]) multipath = os.pathsep.join(path_list) args = self.parser.parse_args(['test', '-r', multipath]) args.output_dir = mock.MagicMock() config = configparser.ConfigParser() config.readfp(StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) update_job_mock.assert_called_with(paths, [], output=args.output_dir) args = self.parser.parse_args(['test', multipath]) config.set('job_builder', 'recursive', 'True') cmd.execute(args, config) update_job_mock.assert_called_with(paths, [], output=args.output_dir)
def test_non_existing_job(self): """ Run test mode and pass a non-existing job name (probably better to fail here) """ args = self.parser.parse_args(["test", os.path.join(self.fixtures_path, "cmd-001.yaml"), "invalid"]) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) # probably better to fail here
def test_delete_multiple_jobs(self, delete_job_mock): """ Test handling the deletion of multiple Jenkins jobs. """ args = self.parser.parse_args(['delete', 'test_job1', 'test_job2']) config = configparser.ConfigParser() config.readfp(StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) # passes if executed without error
def test_delete_multiple_jobs(self, delete_job_mock): """ Test handling the deletion of multiple Jenkins jobs. """ args = self.parser.parse_args(['delete', 'test_job1', 'test_job2']) config = configparser.ConfigParser() config.readfp(StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) # passes if executed without error
def test_update_jobs_and_delete_old(self, builder_mock, delete_job_mock, get_jobs_mock, is_job_mock): """ Test update behaviour with --delete-old option Test update of jobs with the --delete-old option enabled, where only some jobs result in has_changed() to limit the number of times update_job is called, and have the get_jobs() method return additional jobs not in the input yaml to test that the code in cmd will call delete_job() after update_job() when '--delete-old' is set but only for the extra jobs. """ # set up some test data jobs = ['old_job001', 'old_job002'] extra_jobs = [{'name': name} for name in jobs] builder_obj = builder.Builder('http://jenkins.example.com', 'doesnot', 'matter', plugins_list={}) # get the instance created by mock and redirect some of the method # mocks to call real methods on a the above test object. b_inst = builder_mock.return_value b_inst.plugins_list = builder_obj.plugins_list b_inst.update_jobs.side_effect = builder_obj.update_jobs b_inst.delete_old_managed.side_effect = builder_obj.delete_old_managed def _get_jobs(): return builder_obj.parser.jobs + extra_jobs get_jobs_mock.side_effect = _get_jobs # override cache to ensure Jenkins.update_job called a limited number # of times self.cache_mock.return_value.has_changed.side_effect = ( [True] * 2 + [False] * 2) path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', '--delete-old', path]) with mock.patch('jenkins_jobs.builder.Jenkins.update_job') as update: with mock.patch('jenkins_jobs.builder.Jenkins.is_managed', return_value=True): cmd.execute(args, self.config) self.assertEquals(2, update.call_count, "Expected Jenkins.update_job to be called '%d' " "times, got '%d' calls instead.\n" "Called with: %s" % (2, update.call_count, update.mock_calls)) calls = [mock.call(name) for name in jobs] self.assertEquals(2, delete_job_mock.call_count, "Expected Jenkins.delete_job to be called '%d' " "times got '%d' calls instead.\n" "Called with: %s" % (2, delete_job_mock.call_count, delete_job_mock.mock_calls)) delete_job_mock.assert_has_calls(calls, any_order=True)
def test_valid_job(self): """ Run test mode and pass a valid job name """ args = self.parser.parse_args([ 'test', os.path.join(self.fixtures_path, 'cmd-001.yaml'), 'foo-job' ]) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) # probably better to fail here
def test_valid_job(self): """ Run test mode and pass a valid job name """ args = self.parser.parse_args(['test', os.path.join(self.fixtures_path, 'cmd-001.yaml'), 'foo-job']) args.output_dir = mock.Mock(wraps=io.BytesIO()) cmd.execute(args, self.config) # probably better to fail here
def test_non_existing_job(self): """ Run test mode and pass a non-existing job name (probably better to fail here) """ args = self.parser.parse_args(['test', os.path.join(self.fixtures_path, 'cmd-001.yaml'), 'invalid']) args.output_dir = mock.MagicMock(wraps=io.BytesIO()) cmd.execute(args, self.config) # probably better to fail here
def test_non_existing_job(self): """ Run test mode and pass a non-existing job name (probably better to fail here) """ args = self.parser.parse_args([ 'test', os.path.join(self.fixtures_path, 'cmd-001.yaml'), 'invalid' ]) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) # probably better to fail here
def test_valid_job(self): """ Run test mode and pass a valid job name """ args = self.parser.parse_args(['test', os.path.join(self.fixtures_path, 'cmd-001.yaml'), 'foo-job']) args.output_dir = mock.MagicMock() config = ConfigParser.ConfigParser() config.readfp(cStringIO.StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) # probably better to fail here
def test_update_jobs(self, update_job_mock): """ Test update_job is called """ # don't care about the value returned here update_job_mock.return_value = ([], [], 0, 0) path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', path]) cmd.execute(args, self.config) update_job_mock.assert_called_with([path], [])
def test_update_jobs(self, update_jobs_mock): """ Test update_job is called """ # don't care about the value returned here update_jobs_mock.return_value = ([], 0) path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', path]) cmd.execute(args, self.config) update_jobs_mock.assert_called_with([path], [], n_workers=mock.ANY)
def test_multi_path(self): """ Run test mode and pass multiple paths. """ path_list = [os.path.join(self.fixtures_path, 'multipath'), self.fixtures_path] multipath = os.pathsep.join(path_list) args = self.parser.parse_args(['test', multipath]) args.output_dir = mock.MagicMock() config = configparser.ConfigParser() config.readfp(StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) self.assertEqual(args.path, path_list)
def test_non_existing_job(self): """ Run test mode and pass a non-existing job name (probably better to fail here) """ args = self.parser.parse_args(['test', os.path.join(self.fixtures_path, 'cmd-001.yaml'), 'invalid']) args.output_dir = mock.MagicMock() config = configparser.ConfigParser() config.readfp(StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) # probably better to fail here
def test_multi_path(self, update_job_mock): """ Run test mode and pass multiple paths. """ path_list = list(os_walk_return_values.keys()) multipath = os.pathsep.join(path_list) args = self.parser.parse_args(["test", multipath]) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) self.assertEqual(args.path, path_list) update_job_mock.assert_called_with(path_list, [], output=args.output_dir)
def test_multi_path(self): """ Run test mode and pass multiple paths. """ path_list = [ os.path.join(self.fixtures_path, 'multipath'), self.fixtures_path ] multipath = os.pathsep.join(path_list) args = self.parser.parse_args(['test', multipath]) args.output_dir = mock.MagicMock() config = configparser.ConfigParser() config.readfp(StringIO(cmd.DEFAULT_CONF)) cmd.execute(args, config) self.assertEqual(args.path, path_list)
def test_multi_path(self, update_job_mock): """ Run test mode and pass multiple paths. """ path_list = list(os_walk_return_values.keys()) multipath = os.pathsep.join(path_list) args = self.parser.parse_args(['test', multipath]) args.output_dir = mock.MagicMock() cmd.execute(args, self.config) self.assertEqual(args.path, path_list) update_job_mock.assert_called_with(path_list, [], output=args.output_dir)
def test_update_jobs_decode_job_output(self, update_job_mock, get_job_md5_mock, get_jobs_mock, is_job_mock): """ Test that job xml output has been decoded before attempting to update """ # don't care about the value returned here update_job_mock.return_value = ([], 0) path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', path]) cmd.execute(args, self.config) self.assertTrue(isinstance(update_job_mock.call_args[0][1], six.text_type))
def test_update_jobs_decode_job_output(self, update_job_mock, get_job_md5_mock, get_jobs_mock, is_job_mock): """ Test that job xml output has been decoded before attempting to update """ # don't care about the value returned here update_job_mock.return_value = ([], 0) path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', path]) cmd.execute(args, self.config) self.assertTrue( isinstance(update_job_mock.call_args[0][1], six.text_type))
def test_update_timeout_not_set(self, jenkins_mock): """Check that timeout is left unset Test that the Jenkins object has the timeout set on it only when provided via the config option. """ path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', path]) with mock.patch('jenkins_jobs.cmd.Builder.update_job') as update_mock: update_mock.return_value = ([], 0) cmd.execute(args, self.config) # unless the timeout is set, should only call with 3 arguments # (url, user, password) self.assertEquals(len(jenkins_mock.call_args[0]), 3)
def test_update_timeout_not_set(self, jenkins_mock): """Check that timeout is left unset Test that the Jenkins object has the timeout set on it only when provided via the config option. """ path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', path]) with mock.patch('jenkins_jobs.cmd.Builder.update_job') as update_mock: update_mock.return_value = ([], 0) cmd.execute(args, self.config) # unless the timeout is set, should only call with 3 arguments # (url, user, password) self.assertEquals(len(jenkins_mock.call_args[0]), 3)
def test_delete_using_glob_params(self, delete_job_mock): """ Test handling the deletion of multiple Jenkins jobs using the glob parameters feature. """ args = self.parser.parse_args([ 'delete', '--path', os.path.join(self.fixtures_path, 'cmd-002.yaml'), '*bar*' ]) cmd.execute(args, self.config) calls = [mock.call('bar001'), mock.call('bar002')] delete_job_mock.assert_has_calls(calls, any_order=True) self.assertEquals( delete_job_mock.call_count, len(calls), "Jenkins.delete_job() was called '%s' times when " "expected '%s'" % (delete_job_mock.call_count, len(calls)))
def test_update_timeout_set(self, jenkins_mock): """Check that timeout is set correctly Test that the Jenkins object has the timeout set on it only when provided via the config option. """ path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', path]) self.config.set('jenkins', 'timeout', '0.2') with mock.patch('jenkins_jobs.cmd.Builder.update_job') as update_mock: update_mock.return_value = ([], 0) cmd.execute(args, self.config) # when timeout is set, the fourth argument to the Jenkins api init # should be the value specified from the config self.assertEquals(jenkins_mock.call_args[0][3], 0.2)
def test_update_timeout_set(self, jenkins_mock): """Check that timeout is set correctly Test that the Jenkins object has the timeout set on it only when provided via the config option. """ path = os.path.join(self.fixtures_path, 'cmd-002.yaml') args = self.parser.parse_args(['update', path]) self.config.set('jenkins', 'timeout', '0.2') with mock.patch('jenkins_jobs.cmd.Builder.update_job') as update_mock: update_mock.return_value = ([], 0) cmd.execute(args, self.config) # when timeout is set, the fourth argument to the Jenkins api init # should be the value specified from the config self.assertEquals(jenkins_mock.call_args[0][3], 0.2)
def test_delete_using_glob_params(self, delete_job_mock): """ Test handling the deletion of multiple Jenkins jobs using the glob parameters feature. """ args = self.parser.parse_args(['delete', '--path', os.path.join(self.fixtures_path, 'cmd-002.yaml'), '*bar*']) cmd.execute(args, self.config) calls = [mock.call('bar001'), mock.call('bar002')] delete_job_mock.assert_has_calls(calls, any_order=True) self.assertEquals(delete_job_mock.call_count, len(calls), "Jenkins.delete_job() was called '%s' times when " "expected '%s'" % (delete_job_mock.call_count, len(calls)))
def test_plugins_info_stub_option(self, registry_mock, generateXML_mock): """ Test handling of plugins_info stub option. """ plugins_info_stub_yaml_file = os.path.join(self.fixtures_path, 'plugins-info.yaml') args = ['--conf', os.path.join(self.fixtures_path, 'cmd-001.conf'), 'test', '-p', plugins_info_stub_yaml_file, os.path.join(self.fixtures_path, 'cmd-001.yaml')] args = self.parser.parse_args(args) with mock.patch('sys.stdout'): cmd.execute(args, self.config) # probably better to fail here with open(plugins_info_stub_yaml_file, 'r') as yaml_file: plugins_info_list = yaml.load(yaml_file) registry_mock.assert_called_with(self.config, plugins_info_list)
def test_plugins_info_stub_option(self, registry_mock, generateXML_mock): """ Test handling of plugins_info stub option. """ plugins_info_stub_yaml_file = os.path.join(self.fixtures_path, 'plugins-info.yaml') args = [ '--conf', os.path.join(self.fixtures_path, 'cmd-001.conf'), 'test', '-p', plugins_info_stub_yaml_file, os.path.join(self.fixtures_path, 'cmd-001.yaml') ] args = self.parser.parse_args(args) with mock.patch('sys.stdout'): cmd.execute(args, self.config) # probably better to fail here with open(plugins_info_stub_yaml_file, 'r') as yaml_file: plugins_info_list = yaml.load(yaml_file) registry_mock.assert_called_with(self.config, plugins_info_list)
def test_plugins_info_stub_option(self, registry_mock, generateXML_mock): """ Test handling of plugins_info stub option. """ plugins_info_stub_yaml_file = os.path.join(self.fixtures_path, "plugins-info.yaml") args = [ "--conf", os.path.join(self.fixtures_path, "cmd-001.conf"), "test", "-p", plugins_info_stub_yaml_file, os.path.join(self.fixtures_path, "cmd-001.yaml"), ] args = self.parser.parse_args(args) with mock.patch("sys.stdout"): cmd.execute(args, self.config) # probably better to fail here with open(plugins_info_stub_yaml_file, "r") as yaml_file: plugins_info_list = yaml.load(yaml_file) registry_mock.assert_called_with(self.config, plugins_info_list)
def run(self, builder_opts, instance_cfg): jjb.execute(builder_opts, instance_cfg)