Exemplo n.º 1
0
 def test_run_command_failure(self, subprocess):
     subprocess.call.return_value = 1
     mixin = CommandProcessorMixin(
         output='js/processed.js',
         command='cat {input} > {output}',
     )
     with self.assertRaises(RuntimeError):
         mixin.run_command('input.txt')
Exemplo n.º 2
0
 def test_run_command(self, subprocess):
     subprocess.call.return_value = 0
     storage = MagicMock()
     storage.path.side_effect = lambda f: os.path.join('/prefix/path/', f)
     mixin = CommandProcessorMixin(
         output='js/processed.js',
         command='cat {input} > {output}',
         storage=storage,
     )
     mixin.run_command('input.txt')
     subprocess.call.assert_called_with(
         ['cat', 'input.txt', '>', '/prefix/path/js/processed.js'])
Exemplo n.º 3
0
 def test_get_command(self):
     mixin = CommandProcessorMixin()
     mixin.command = 'cat {input} > {output}'
     command = mixin.get_command(
         input='/an/input/file.txt', output='output.txt')
     self.assertEqual(command, 'cat /an/input/file.txt > output.txt')
Exemplo n.º 4
0
 def test_bails_on_no_input(self, subprocess):
     mixin = CommandProcessorMixin(require_input=True)
     mixin.run_command('')
     self.assertFalse(subprocess.call.called)