def _test_subworkflow(self, env): self.override_config('type', 'remote', 'executor') wf2_ex = self.engine.start_workflow('my_wb.wf2', env=env) # Execution of 'wf2'. self.assertIsNotNone(wf2_ex) self.assertDictEqual({}, wf2_ex.input) self._await(lambda: len(db_api.get_workflow_executions()) == 2, 0.5, 5) with db_api.transaction(): wf_execs = db_api.get_workflow_executions() self.assertEqual(2, len(wf_execs)) # Execution of 'wf1'. wf2_ex = self._assert_single_item(wf_execs, name='my_wb.wf2') wf1_ex = self._assert_single_item(wf_execs, name='my_wb.wf1') expected_wf1_input = {'param1': 'Bonnie', 'param2': 'Clyde'} self.assertIsNotNone(wf1_ex.task_execution_id) self.assertDictEqual(wf1_ex.input, expected_wf1_input) # Wait till workflow 'wf1' is completed. self.await_workflow_success(wf1_ex.id) with db_api.transaction(): wf1_ex = db_api.get_workflow_execution(wf1_ex.id) self.assertDictEqual({'final_result': "'Bonnie & Clyde'"}, wf1_ex.output) # Wait till workflow 'wf2' is completed. self.await_workflow_success(wf2_ex.id) with db_api.transaction(): wf2_ex = db_api.get_workflow_execution(wf2_ex.id) self.assertDictEqual( {'slogan': "'Bonnie & Clyde' is a cool movie!\n"}, wf2_ex.output) with db_api.transaction(): # Check if target is resolved. wf1_task_execs = db_api.get_task_executions( workflow_execution_id=wf1_ex.id) self._assert_single_item(wf1_task_execs, name='task1') self._assert_single_item(wf1_task_execs, name='task2') for t_ex in wf1_task_execs: a_ex = t_ex.action_executions[0] callback_url = '/v2/action_executions/%s' % a_ex.id r_exe.RemoteExecutor.run_action.assert_any_call( std_actions.EchoAction(**a_ex.input), a_ex.id, False, { 'task_execution_id': t_ex.id, 'callback_url': callback_url, 'workflow_execution_id': wf1_ex.id, 'workflow_name': wf1_ex.name, 'action_execution_id': a_ex.id, }, target=TARGET, timeout=None)
def test_fake_action(self): expected = "my output" mock_ctx = mock.Mock() action = std.EchoAction(expected) self.assertEqual(expected, action.run(mock_ctx))
def test_fake_action(self): expected = "my output" action = std.EchoAction(expected) self.assertEqual(expected, action.run())