def _run(self, ctx_kwargs, expected_script_path, actual_script_path,
             return_result=False, pass_parameter=False):
        def mock_download_resource(script_path):
            self.assertEqual(script_path, expected_script_path)
            return actual_script_path

        if 'properties' not in ctx_kwargs:
            ctx_kwargs['properties'] = {}
        if 'process' not in ctx_kwargs['properties']:
            ctx_kwargs['properties']['process'] = {}
        process_config = ctx_kwargs['properties']['process']
        process_config.update({
            'ctx_proxy_type': self.ctx_proxy_type
        })

        ctx = MockCloudifyContext(**ctx_kwargs)
        ctx.download_resource = mock_download_resource
        if pass_parameter:
            result = tasks.run(expected_script_path, ctx=ctx)
        else:
            result = tasks.run(ctx=ctx)
        if return_result:
            return ctx, result
        else:
            return ctx
Esempio n. 2
0
 def test_implicit_execute(self):
     self.expected_call = 'execute'
     tasks.run('script_path', ctx=self.mock_ctx())
Esempio n. 3
0
 def test_explicit_execute_with_py_extension(self):
     self.expected_call = 'execute'
     tasks.run('script_path.py',
               process={'eval_python': False},
               ctx=self.mock_ctx())
Esempio n. 4
0
 def test_implicit_eval(self):
     self.expected_call = 'eval'
     tasks.run('script_path.py', ctx=self.mock_ctx())
Esempio n. 5
0
 def test_explicit_eval_with_py_extenstion(self):
     self.expected_call = 'eval'
     tasks.run('script_path.py',
               process={'eval_python': True},
               ctx=self.mock_ctx())
 def test_implicit_execute(self):
     self.expected_call = 'execute'
     tasks.run('script_path',
               ctx=self.mock_ctx())
 def test_explicit_execute_with_py_extension(self):
     self.expected_call = 'execute'
     tasks.run('script_path.py',
               process={'eval_python': False},
               ctx=self.mock_ctx())
 def test_implicit_eval(self):
     self.expected_call = 'eval'
     tasks.run('script_path.py',
               ctx=self.mock_ctx())
 def test_explicit_eval_with_py_extenstion(self):
     self.expected_call = 'eval'
     tasks.run('script_path.py',
               process={'eval_python': True},
               ctx=self.mock_ctx())
Esempio n. 10
0
 def test_explicit_powershell_call(self, mock_chmod):
     self.expected_call = 'execute'
     tasks.run('script_path.psx',
               process={'command_prefix': 'powershell'},
               ctx=self.mock_ctx())
     self.assertEqual(self.process['command_prefix'], 'powershell')
Esempio n. 11
0
 def test_command_prefix_is_overriden_for_ps1_extension(self, mock_chmod):
     self.expected_call = 'execute'
     tasks.run('script_path.ps1',
               process={'command_prefix': 'bash'},
               ctx=self.mock_ctx())
     self.assertEqual(self.process['command_prefix'], 'bash')
Esempio n. 12
0
 def test_implicit_powershell_call_with_ps1_extension(self, mock_chmod):
     self.expected_call = 'execute'
     tasks.run('script_path.ps1',
               ctx=self.mock_ctx())
     self.assertEqual(self.process['command_prefix'], 'powershell')
 def test_implicit_execute(self):
     self.expected_call = 'execute'
     tasks.get_script_to_run = lambda script_path, ctx: 'script_path'
     tasks.run(ctx=MockCloudifyContext())
 def test_explicit_execute_with_py_extension(self):
     self.expected_call = 'execute'
     tasks.get_script_to_run = lambda script_path, ctx: 'script_path.py'
     tasks.run(ctx=MockCloudifyContext(properties={
         'process': {'eval_python': False}
     }))
 def test_explicit_eval_without_py_extenstion(self):
     self.expected_call = 'eval'
     tasks.get_script_to_run = lambda script_path, ctx: 'script_path'
     tasks.run(ctx=MockCloudifyContext(properties={
         'process': {'eval_python': True}
     }))