def test_ffkExecutionEventsCase(self): c = Controller(name="testStepFFKEventsController") c.load_workflows_from_file(path=config.test_workflows_path + "basicWorkflowTest.playbook") workflow_name = construct_workflow_name_key('basicWorkflowTest', 'helloWorldWorkflow') filter_sub = Subscription(events=['Filter Error']) flag_sub = Subscription(events=['Flag Success', 'Flag Error'], subscriptions={'length': filter_sub}) next_sub = Subscription( events=['Next Step Taken', 'Next Step Not Taken'], subscriptions={'regMatch': flag_sub}) step_sub = Subscription(events=[ 'Function Execution Success', 'Input Validated', 'Conditionals Executed' ], subscriptions={'1': next_sub}) subs = { 'testStepFFKEventsController': Subscription( subscriptions={ workflow_name: Subscription( subscriptions={'start': step_sub}) }) } global_subs = case_subscription.GlobalSubscriptions( step=[ 'Function Execution Success', 'Input Validated', 'Conditionals Executed' ], next_step=['Next Step Taken', 'Next Step Not Taken'], flag=['Flag Success', 'Flag Error'], filter=['Filter Error']) case_subscription.set_subscriptions({ 'testStepFFKEventsEvents': case_subscription.CaseSubscriptions( subscriptions=subs, global_subscriptions=global_subs) }) c.execute_workflow('basicWorkflowTest', 'helloWorldWorkflow') shutdown_pool() step_ffk_events_case = case_database.case_db.session.query(case_database.Case) \ .filter(case_database.Case.name == 'testStepFFKEventsEvents').first() step_ffk_event_history = step_ffk_events_case.events.all() self.assertEqual( len(step_ffk_event_history), 5, 'Incorrect length of event history. ' 'Expected {0}, got {1}'.format(5, len(step_ffk_event_history))) step_json = [ step.as_json() for step in step_ffk_event_history if step.as_json()['message'] == 'STEP' ] for step in step_json: if step['type'] == 'Function executed successfully': self.assertDictEqual(step['data'], {'result': 'REPEATING: Hello World'}) else: self.assertEqual(step['data'], '')
def edit_global_subscription(case_name): form = forms.EditGlobalSubscriptionForm(request.form) if form.validate(): global_sub = case_subscription.GlobalSubscriptions( controller=form.controller.data, workflow=form.workflow.data, step=form.step.data, next_step=form.next_step.data, flag=form.flag.data, filter=form.filter.data) success = case_subscription.edit_global_subscription( case_name, global_sub) if success: return json.dumps(case_subscription.subscriptions_as_json()) else: return json.dumps({ "status": "Error: Case name {0} was not found".format(case_name) }) else: return json.dumps({"status": "Error: form invalid"})
def test_ffkExecutionEventsCase(self): c = controller.Controller(name="testStepFFKEventsController") c.loadWorkflowsFromFile(path=config.testWorkflowsPath + "basicWorkflowTest.workflow") filter_sub = Subscription(disabled=['FilterSuccess']) flag_sub = Subscription(subscriptions={'length': filter_sub}) next_sub = Subscription(subscriptions={'regMatch': flag_sub}) step_sub = Subscription(subscriptions={'1': next_sub}) subs = { 'testStepFFKEventsController': Subscription( subscriptions={ 'helloWorldWorkflow': Subscription(subscriptions={'start': step_sub}) }) } global_subs = case_subscription.GlobalSubscriptions( step='*', next_step=['NextStepTaken', 'NextStepNotTaken'], flag=['FlagArgsValid', 'FlagArgsInvalid'], filter=['FilterSuccess', 'FilterError']) case_subscription.set_subscriptions({ 'testStepFFKEventsEvents': case_subscription.CaseSubscriptions( subscriptions=subs, global_subscriptions=global_subs) }) c.executeWorkflow(name="helloWorldWorkflow") step_ffk_events_case = case_database.case_db.session.query(case_database.Cases) \ .filter(case_database.Cases.name == 'testStepFFKEventsEvents').first() step_ffk_event_history = step_ffk_events_case.events.all() self.assertEqual( len(step_ffk_event_history), 5, 'Incorrect length of event history. ' 'Expected {0}, got {1}'.format(5, len(step_ffk_event_history)))