Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
 def test_init(self):
     script_inv = ScriptInvocation(
         self.provider, self.config, self.job_name)
     self.assertIs(script_inv.provider, self.provider)
     self.assertIs(script_inv.config, self.config)
     self.assertIs(script_inv.job_name, self.job_name)
Ejemplo n.º 14
0
 def test_init(self):
     script_inv = ScriptInvocation(self.provider_list, self.config,
                                   self.job_id)
     self.assertIs(script_inv.provider_list, self.provider_list)
     self.assertIs(script_inv.config, self.config)
     self.assertIs(script_inv.job_id, self.job_id)