def test_lookup_with_two_spreadsheets_with_the_same_field_name_in_different_forms( self): spec = BaseTest.load_test_spec('enum_options_competing_files') workflow = self.create_workflow('enum_options_competing_files') processor = WorkflowProcessor(workflow) processor.do_engine_steps() task = processor.get_ready_user_tasks()[0] task.data = {"type": "animals"} processor.complete_task(task) processor.do_engine_steps() task = processor.get_ready_user_tasks()[0] results = LookupService.lookup(workflow, task.task_spec.name, "selectedItem", "", value="pigs", limit=10) self.assertEqual( 1, len(results), "It is possible to find an item based on the id, rather than as a search" ) self.assertIsNotNone(results[0]) results = LookupService.lookup(workflow, task.task_spec.name, "selectedItem", "", value="apples", limit=10) self.assertEqual( 0, len(results), "We shouldn't find our fruits mixed in with our animals.") processor = WorkflowProcessor.reset(workflow, clear_data=True) processor.do_engine_steps() task = processor.get_ready_user_tasks()[0] task.data = {"type": "fruits"} processor.complete_task(task) processor.do_engine_steps() task = processor.get_ready_user_tasks()[0] results = LookupService.lookup(workflow, task.task_spec.name, "selectedItem", "", value="apples", limit=10) self.assertEqual( 1, len(results), "It is possible to find an item based on the id, rather than as a search" ) self.assertIsNotNone(results[0]) results = LookupService.lookup(workflow, task.task_spec.name, "selectedItem", "", value="pigs", limit=10) self.assertEqual( 0, len(results), "We shouldn't find our animals mixed in with our fruits.")
def test_timer_event(self): workflow = self.create_workflow('timer_event') processor = WorkflowProcessor(workflow) processor.do_engine_steps() task = processor.next_task() processor.complete_task(task) tasks = processor.get_ready_user_tasks() self.assertEqual(tasks, []) processor.save() time.sleep(.3) # our timer is at .25 sec so we have to wait for it # get done waiting WorkflowService.do_waiting() wf = db.session.query(WorkflowModel).filter( WorkflowModel.id == workflow.id).first() self.assertTrue(wf.status != WorkflowStatus.waiting)
def test_load_irb_from_db(self, mock_study_service): # This depends on getting a list of investigators back from the protocol builder. mock_study_service.return_value = self.mock_investigator_response self.load_example_data() workflow_spec_model = self.create_workflow("irb_api_personnel") study = session.query(StudyModel).first() processor = WorkflowProcessor(workflow_spec_model) processor.do_engine_steps() task_list = processor.get_ready_user_tasks() processor.complete_task(task_list[0]) processor.do_engine_steps() nav_list = processor.bpmn_workflow.get_flat_nav_list() processor.save() # reload after save processor = WorkflowProcessor(workflow_spec_model) nav_list2 = processor.bpmn_workflow.get_flat_nav_list() self.assertEqual(nav_list, nav_list2)