Exemple #1
0
 def test_fabric_remote_script_action_method(self):
     remote_action = FabricRemoteScriptAction('foo', 'foo-id', '/tmp/st2.py',
                                              None,
                                              on_behalf_user='******',
                                              parallel=True, sudo=False)
     self.assertEqual(remote_action.get_on_behalf_user(), 'stan')
     fabric_task = remote_action.get_fabric_task()
     self.assertTrue(fabric_task is not None)
     self.assertTrue(fabric_task.wrapped == remote_action._run_script)
Exemple #2
0
    def test_settings_are_used(self, mock_settings, mock_shell_env, mock_put, mock_run):
        # Test that the remote script action uses fabric environment and authentication settings
        named_args = {}
        action = FabricRemoteScriptAction(name='foo', action_exec_id='dummy',
                                          script_local_path_abs='test.py',
                                          script_local_libs_path_abs='/',
                                          remote_dir='/tmp',
                                          named_args=named_args, positional_args=None)

        task = action.get_fabric_task()

        self.assertEqual(mock_settings.call_count, 0)
        self.assertEqual(mock_shell_env.call_count, 0)
        task.run()
        self.assertEqual(mock_settings.call_count, 1)
        self.assertEqual(mock_shell_env.call_count, 1)
    def test_settings_are_used(self, mock_settings, mock_shell_env, mock_put,
                               mock_run):
        # Test that the remote script action uses fabric environment and authentication settings
        named_args = {}
        action = FabricRemoteScriptAction(name='foo',
                                          action_exec_id='dummy',
                                          script_local_path_abs='test.py',
                                          script_local_libs_path_abs='/',
                                          remote_dir='/tmp',
                                          named_args=named_args,
                                          positional_args=None)

        task = action.get_fabric_task()

        self.assertEqual(mock_settings.call_count, 0)
        self.assertEqual(mock_shell_env.call_count, 0)
        task.run()
        self.assertEqual(mock_settings.call_count, 1)
        self.assertEqual(mock_shell_env.call_count, 1)