Пример #1
0
 def setUp(self):
     self.job_list = [make_job('foo'), make_job('bar')]
     self.whitelist_list = [
         WhiteList([], name='ihv-foo'), WhiteList([], name='other')]
     self.real_provider = DummyProvider1(
         job_list=self.job_list, whitelist_list=self.whitelist_list)
     self.ihv_provider = IHVProvider(self.real_provider)
Пример #2
0
 def test_run_job_without_command(self):
     provider_list = [DummyProvider1([make_job(self.JOB_PARTIAL_ID)])]
     script_inv = ScriptInvocation(provider_list, self.config, self.JOB_ID)
     with TestIO() as io:
         retval = script_inv.run()
     self.assertCommandOutput(io.stdout, ("""
             Selected job does not have a command
             """))
     self.assertEqual(retval, 125)
Пример #3
0
 def test_run_no_such_job(self):
     provider_list = [DummyProvider1()]
     script_inv = ScriptInvocation(provider_list, self.config, self.JOB_ID)
     with TestIO() as io:
         retval = script_inv.run()
     self.assertCommandOutput(io.stdout, ("""
             There is no job called '{job_id}'
             See `plainbox special --list-jobs` for a list of choices
             """).format(job_id=self.JOB_ID))
     self.assertEqual(retval, 126)
Пример #4
0
 def test_run_job_without_command(self):
     provider = DummyProvider1([make_job('foo')])
     script_inv = ScriptInvocation(provider, self.config, 'foo')
     with TestIO() as io:
         retval = script_inv.run()
     self.assertEqual(
         io.stdout, cleandoc(
             """
             Selected job does not have a command
             """) + '\n')
     self.assertEqual(retval, 125)
Пример #5
0
 def test_run_no_such_job(self):
     provider = DummyProvider1()
     script_inv = ScriptInvocation(provider, self.config, 'foo')
     with TestIO() as io:
         retval = script_inv.run()
     self.assertEqual(
         io.stdout, cleandoc(
             """
             There is no job called 'foo'
             See `plainbox special --list-jobs` for a list of choices
             """) + '\n')
     self.assertEqual(retval, 126)
Пример #6
0
 def test_job_with_command(self, mock_check_output):
     provider_list = [
         DummyProvider1([make_job(self.JOB_PARTIAL_ID, command='echo ok')])
     ]
     script_inv = ScriptInvocation(provider_list, self.config, self.JOB_ID)
     with TestIO() as io:
         retval = script_inv.run()
     self.assertCommandOutput(io.stdout, ("""
             (job {job_id}, <stdout:00001>) ok
             job {job_id} returned 0
             command: echo ok
             """).format(job_id=self.JOB_ID))
     self.assertEqual(retval, 0)
Пример #7
0
 def test_job_with_command(self):
     dummy_name = 'foo'
     dummy_command = 'echo ok'
     provider = DummyProvider1([
         make_job(dummy_name, command=dummy_command)])
     script_inv = ScriptInvocation(provider, self.config, dummy_name)
     with TestIO() as io:
         retval = script_inv.run()
     self.assertEqual(
         io.stdout, cleandoc(
             """
             (job foo, <stdout:00001>) ok
             """) + '\n' + "{} returned 0\n".format(dummy_name) +
             "command: {}\n".format(dummy_command))
     self.assertEqual(retval, 0)
Пример #8
0
 def test_job_with_command_making_files(self, mock_check_output):
     provider_list = [
         DummyProvider1(
             [make_job(self.JOB_PARTIAL_ID, command='echo ok > file')])
     ]
     script_inv = ScriptInvocation(provider_list, self.config, self.JOB_ID)
     with TestIO() as io:
         retval = script_inv.run()
     self.maxDiff = None
     self.assertCommandOutput(io.stdout, ("""
             Leftover file detected: 'files-created-in-current-dir/file':
               files-created-in-current-dir/file:1: ok
             job {job_id} returned 0
             command: echo ok > file
             """).format(job_id=self.JOB_ID))
     self.assertEqual(retval, 0)
Пример #9
0
 def test_job_with_command_making_files(self):
     dummy_name = 'foo'
     dummy_command = 'echo ok > file'
     provider = DummyProvider1([
         make_job(dummy_name, command=dummy_command)])
     script_inv = ScriptInvocation(provider, self.config, dummy_name)
     with TestIO() as io:
         retval = script_inv.run()
     self.maxDiff = None
     self.assertEqual(
         io.stdout, cleandoc(
             """
             Leftover file detected: 'files-created-in-current-dir/file':
               files-created-in-current-dir/file:1: ok
             """) + '\n' + "{} returned 0\n".format(dummy_name) +
             "command: {}\n".format(dummy_command))
     self.assertEqual(retval, 0)