diff --git a/tests/study/test_study_cancellations.py b/tests/study/test_study_cancellations.py index 4b0d61f9..df0ba2a2 100644 --- a/tests/study/test_study_cancellations.py +++ b/tests/study/test_study_cancellations.py @@ -72,7 +72,7 @@ class TestStudyCancellations(BaseTest): workflow, study_id = self.load_workflow() workflow_api, first_task = self.get_first_task(workflow) - self.complete_form(workflow_api, first_task, {}) + self.complete_form(workflow, first_task, {}) study_result = self.put_study_on_hold(study_id) self.assertEqual('New Title', study_result.title) @@ -82,10 +82,10 @@ class TestStudyCancellations(BaseTest): workflow, study_id = self.load_workflow() workflow_api, first_task = self.get_first_task(workflow) - self.complete_form(workflow_api, first_task, {}) + self.complete_form(workflow, first_task, {}) workflow_api, next_task = self.get_second_task(workflow) - self.complete_form(workflow_api, next_task, {'how_many': 3}) + self.complete_form(workflow, next_task, {'how_many': 3}) study_result = self.put_study_on_hold(study_id) self.assertEqual('Second Title', study_result.title) @@ -95,13 +95,13 @@ class TestStudyCancellations(BaseTest): workflow, study_id = self.load_workflow() workflow_api, first_task = self.get_first_task(workflow) - self.complete_form(workflow_api, first_task, {}) + self.complete_form(workflow, first_task, {}) workflow_api, second_task = self.get_second_task(workflow) - self.complete_form(workflow_api, second_task, {'how_many': 3}) + self.complete_form(workflow, second_task, {'how_many': 3}) workflow_api, third_task = self.get_third_task(workflow) - self.complete_form(workflow_api, third_task, {}) + self.complete_form(workflow, third_task, {}) study_result = self.put_study_on_hold(study_id) self.assertEqual('Beer consumption in the bipedal software engineer', study_result.title) diff --git a/tests/test_email_script.py b/tests/test_email_script.py index 980d0c06..7786b045 100644 --- a/tests/test_email_script.py +++ b/tests/test_email_script.py @@ -23,7 +23,6 @@ class TestEmailScript(BaseTest): first_task = self.get_workflow_api(workflow).next_task - workflow = self.get_workflow_api(workflow) self.complete_form(workflow, first_task, {'subject': 'My Email Subject', 'recipients': 'test@example.com'}) self.assertEqual(1, len(outbox)) @@ -49,7 +48,6 @@ class TestEmailScript(BaseTest): def test_bad_email_address_1(self): workflow = self.create_workflow('email_script') first_task = self.get_workflow_api(workflow).next_task - workflow = self.get_workflow_api(workflow) with self.assertRaises(AssertionError): self.complete_form(workflow, first_task, {'recipients': 'test@example'}) @@ -57,7 +55,6 @@ class TestEmailScript(BaseTest): def test_bad_email_address_2(self): workflow = self.create_workflow('email_script') first_task = self.get_workflow_api(workflow).next_task - workflow = self.get_workflow_api(workflow) with self.assertRaises(AssertionError): self.complete_form(workflow, first_task, {'recipients': 'test'}) diff --git a/tests/test_message_event.py b/tests/test_message_event.py index f761871b..3d769095 100644 --- a/tests/test_message_event.py +++ b/tests/test_message_event.py @@ -13,10 +13,10 @@ class TestMessageEvent(BaseTest): # Start the workflow. first_task = self.get_workflow_api(workflow).next_task self.assertEqual('Activity_GetData', first_task.name) - workflow = self.get_workflow_api(workflow) + self.complete_form(workflow, first_task, {'formdata': 'asdf'}) - workflow = self.get_workflow_api(workflow) - self.assertEqual('Activity_HowMany', workflow.next_task.name) + workflow_api = self.get_workflow_api(workflow) + self.assertEqual('Activity_HowMany', workflow_api.next_task.name) # reset the workflow # this ultimately calls crc.api.workflow.set_current_task diff --git a/tests/test_multi_instance_tasks_api.py b/tests/test_multi_instance_tasks_api.py index d4f26297..12036e2d 100644 --- a/tests/test_multi_instance_tasks_api.py +++ b/tests/test_multi_instance_tasks_api.py @@ -67,14 +67,14 @@ class TestMultiinstanceTasksApi(BaseTest): content_type="application/json") self.assert_success(rv) json_data = json.loads(rv.get_data(as_text=True)) - workflow = WorkflowApiSchema().load(json_data) - data = workflow.next_task.data + workflow_api = WorkflowApiSchema().load(json_data) + data = workflow_api.next_task.data data['investigator']['email'] = "dhf8r@virginia.edu" - self.complete_form(workflow, workflow.next_task, data) + self.complete_form(workflow, workflow_api.next_task, data) #tasks = self.get_workflow_api(workflow).user_tasks - workflow = self.get_workflow_api(workflow) - self.assertEqual(WorkflowStatus.complete, workflow.status) + workflow_api = self.get_workflow_api(workflow) + self.assertEqual(WorkflowStatus.complete, workflow_api.status) @patch('crc.services.protocol_builder.requests.get') diff --git a/tests/test_tasks_api.py b/tests/test_tasks_api.py index f2742960..9c6f0b41 100644 --- a/tests/test_tasks_api.py +++ b/tests/test_tasks_api.py @@ -386,15 +386,15 @@ class TestTasksApi(BaseTest): # Start the workflow. first_task = self.get_workflow_api(workflow).next_task self.complete_form(workflow, first_task, {"has_bananas": True}) - workflow = self.get_workflow_api(workflow) - self.assertEqual('Task_Num_Bananas', workflow.next_task.name) + workflow_api = self.get_workflow_api(workflow) + self.assertEqual('Task_Num_Bananas', workflow_api.next_task.name) # Trying to re-submit the initial task, and answer differently, should result in an error. self.complete_form(workflow, first_task, {"has_bananas": False}, error_code="invalid_state") # Go ahead and set the number of bananas. - workflow = self.get_workflow_api(workflow) - task = workflow.next_task + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task self.complete_form(workflow, task, {"num_bananas": 4}) # We are now at the end of the workflow. @@ -405,19 +405,19 @@ class TestTasksApi(BaseTest): content_type="application/json") self.assert_success(rv) json_data = json.loads(rv.get_data(as_text=True)) - workflow = WorkflowApiSchema().load(json_data) + workflow_api = WorkflowApiSchema().load(json_data) # Assure the Next Task is the one we just reset the token to be on. - self.assertEqual("Task_Has_Bananas", workflow.next_task.name) + self.assertEqual("Task_Has_Bananas", workflow_api.next_task.name) # Go ahead and get that workflow one more time, it should still be right. - workflow = self.get_workflow_api(workflow) + workflow_api = self.get_workflow_api(workflow) # Assure the Next Task is the one we just reset the token to be on. - self.assertEqual("Task_Has_Bananas", workflow.next_task.name) + self.assertEqual("Task_Has_Bananas", workflow_api.next_task.name) # The next task should be a different value. - self.complete_form(workflow, workflow.next_task, {"has_bananas": False}) - workflow = self.get_workflow_api(workflow) - self.assertEqual('Task_Why_No_Bananas', workflow.next_task.name) + self.complete_form(workflow, workflow_api.next_task, {"has_bananas": False}) + workflow_api = self.get_workflow_api(workflow) + self.assertEqual('Task_Why_No_Bananas', workflow_api.next_task.name) diff --git a/tests/workflow/test_workflow_boolean_default.py b/tests/workflow/test_workflow_boolean_default.py index 1773295a..a2b04228 100644 --- a/tests/workflow/test_workflow_boolean_default.py +++ b/tests/workflow/test_workflow_boolean_default.py @@ -7,7 +7,7 @@ class TestBooleanDefault(BaseTest): workflow = self.create_workflow('boolean_default_value') workflow_api = self.get_workflow_api(workflow) set_default_task = workflow_api.next_task - result = self.complete_form(workflow_api, set_default_task, {'yes_no': yes_no}) + result = self.complete_form(workflow, set_default_task, {'yes_no': yes_no}) return result def test_boolean_true_string(self): diff --git a/tests/workflow/test_workflow_enum_default_value_expression.py b/tests/workflow/test_workflow_enum_default_value_expression.py index 00c2abf6..644d52f8 100644 --- a/tests/workflow/test_workflow_enum_default_value_expression.py +++ b/tests/workflow/test_workflow_enum_default_value_expression.py @@ -7,35 +7,35 @@ class TestWorkflowEnumDefault(BaseTest): def test_enum_default_from_value_expression(self): workflow = self.create_workflow('enum_value_expression') - first_task = self.get_workflow_api(workflow).next_task - self.assertEqual('Activity_UserInput', first_task.name) workflow_api = self.get_workflow_api(workflow) + first_task = workflow_api.next_task + self.assertEqual('Activity_UserInput', first_task.name) - result = self.complete_form(workflow_api, first_task, {'user_input': True}) + result = self.complete_form(workflow, first_task, {'user_input': True}) self.assertIn('user_input', result.next_task.data) self.assertEqual(True, result.next_task.data['user_input']) self.assertIn('lookup_output', result.next_task.data) self.assertEqual('black', result.next_task.data['lookup_output']) workflow_api = self.get_workflow_api(workflow) - self.assertEqual('Activity_PickColor', self.get_workflow_api(workflow_api).next_task.name) + self.assertEqual('Activity_PickColor', workflow_api.next_task.name) self.assertEqual({'value': 'black', 'label': 'Black'}, workflow_api.next_task.data['color_select']) # workflow = self.create_workflow('enum_value_expression') - first_task = self.get_workflow_api(workflow).next_task - self.assertEqual('Activity_UserInput', first_task.name) workflow_api = self.get_workflow_api(workflow) + first_task = workflow_api.next_task + self.assertEqual('Activity_UserInput', first_task.name) - result = self.complete_form(workflow_api, first_task, {'user_input': False}) + result = self.complete_form(workflow, first_task, {'user_input': False}) self.assertIn('user_input', result.next_task.data) self.assertEqual(False, result.next_task.data['user_input']) self.assertIn('lookup_output', result.next_task.data) self.assertEqual('white', result.next_task.data['lookup_output']) workflow_api = self.get_workflow_api(workflow) - self.assertEqual('Activity_PickColor', self.get_workflow_api(workflow_api).next_task.name) + self.assertEqual('Activity_PickColor', workflow_api.next_task.name) self.assertEqual({'value': 'white', 'label': 'White'}, workflow_api.next_task.data['color_select']) def test_enum_value_expression_and_default(self): diff --git a/tests/workflow/test_workflow_form_field_name.py b/tests/workflow/test_workflow_form_field_name.py index 8a6aead2..6e38a816 100644 --- a/tests/workflow/test_workflow_form_field_name.py +++ b/tests/workflow/test_workflow_form_field_name.py @@ -18,7 +18,7 @@ class TestFormFieldName(BaseTest): workflow_api = self.get_workflow_api(workflow) first_task = workflow_api.next_task - self.complete_form(workflow_api, first_task, {}) + self.complete_form(workflow, first_task, {}) workflow_api = self.get_workflow_api(workflow) second_task = workflow_api.next_task diff --git a/tests/workflow/test_workflow_hidden_required_field.py b/tests/workflow/test_workflow_hidden_required_field.py index b77dbb24..610c917d 100644 --- a/tests/workflow/test_workflow_hidden_required_field.py +++ b/tests/workflow/test_workflow_hidden_required_field.py @@ -34,14 +34,13 @@ class TestWorkflowHiddenRequiredField(BaseTest): first_task = workflow_api.next_task self.assertEqual('Activity_Hello', first_task.name) - workflow_api = self.get_workflow_api(workflow) - self.complete_form(workflow_api, first_task, {}) + self.complete_form(workflow, first_task, {}) workflow_api = self.get_workflow_api(workflow) second_task = workflow_api.next_task self.assertEqual('Activity_HiddenField', second_task.name) - self.complete_form(workflow_api, second_task, {}) + self.complete_form(workflow, second_task, {}) workflow_api = self.get_workflow_api(workflow) # The color field is hidden and required. Make sure we use the default value diff --git a/tests/workflow/test_workflow_restart.py b/tests/workflow/test_workflow_restart.py index 98688964..0aafb492 100644 --- a/tests/workflow/test_workflow_restart.py +++ b/tests/workflow/test_workflow_restart.py @@ -9,20 +9,20 @@ class TestWorkflowRestart(BaseTest): workflow = self.create_workflow('message_event') - first_task = self.get_workflow_api(workflow).next_task - self.assertEqual('Activity_GetData', first_task.name) workflow_api = self.get_workflow_api(workflow) + first_task = workflow_api.next_task + self.assertEqual('Activity_GetData', first_task.name) - result = self.complete_form(workflow_api, first_task, {'formdata': 'asdf'}) + result = self.complete_form(workflow, first_task, {'formdata': 'asdf'}) self.assertIn('formdata', result.next_task.data) self.assertEqual('asdf', result.next_task.data['formdata']) workflow_api = self.get_workflow_api(workflow) - self.assertEqual('Activity_HowMany', self.get_workflow_api(workflow_api).next_task.name) + self.assertEqual('Activity_HowMany', workflow_api.next_task.name) # restart with data. should land at beginning with data workflow_api = self.restart_workflow_api(result) - first_task = self.get_workflow_api(workflow_api).next_task + first_task = workflow_api.next_task self.assertEqual('Activity_GetData', first_task.name) self.assertIn('formdata', workflow_api.next_task.data) self.assertEqual('asdf', workflow_api.next_task.data['formdata']) @@ -33,21 +33,19 @@ class TestWorkflowRestart(BaseTest): self.assertEqual('Activity_GetData', first_task.name) self.assertNotIn('formdata', workflow_api.next_task.data) - print('Nice Test') - def test_workflow_restart_on_cancel_notify(self): workflow = self.create_workflow('message_event') study_id = workflow.study_id # Start the workflow. - first_task = self.get_workflow_api(workflow).next_task - self.assertEqual('Activity_GetData', first_task.name) workflow_api = self.get_workflow_api(workflow) - self.complete_form(workflow_api, first_task, {'formdata': 'asdf'}) + first_task = workflow_api.next_task + self.assertEqual('Activity_GetData', first_task.name) + self.complete_form(workflow, first_task, {'formdata': 'asdf'}) workflow_api = self.get_workflow_api(workflow) self.assertEqual('Activity_HowMany', workflow_api.next_task.name) - workflow_api = self.restart_workflow_api(workflow) + self.restart_workflow_api(workflow) study_result = session.query(StudyModel).filter(StudyModel.id == study_id).first() self.assertEqual('New Title', study_result.title) @@ -66,17 +64,16 @@ class TestWorkflowRestart(BaseTest): study_id = workflow.study_id # Start the workflow. - first_task = self.get_workflow_api(workflow).next_task - self.assertEqual('Activity_GetData', first_task.name) workflow_api = self.get_workflow_api(workflow) - self.complete_form(workflow_api, first_task, {'formdata': 'asdf'}) + first_task = workflow_api.next_task + self.assertEqual('Activity_GetData', first_task.name) + self.complete_form(workflow, first_task, {'formdata': 'asdf'}) workflow_api = self.get_workflow_api(workflow) next_task = workflow_api.next_task self.assertEqual('Activity_HowMany', next_task.name) - self.complete_form(workflow_api, next_task, {'how_many': 3}) + self.complete_form(workflow, next_task, {'how_many': 3}) - workflow_api = self.restart_workflow_api(workflow) study_result = session.query(StudyModel).filter(StudyModel.id == study_id).first() self.assertEqual('Beer consumption in the bipedal software engineer', study_result.title) diff --git a/tests/workflow/test_workflow_value_expression.py b/tests/workflow/test_workflow_value_expression.py index d527c694..47751b1c 100644 --- a/tests/workflow/test_workflow_value_expression.py +++ b/tests/workflow/test_workflow_value_expression.py @@ -9,7 +9,7 @@ class TestValueExpression(BaseTest): workflow_api = self.get_workflow_api(workflow) first_task = workflow_api.next_task - self.complete_form(workflow_api, first_task, {'value_expression_value': ''}) + self.complete_form(workflow, first_task, {'value_expression_value': ''}) workflow_api = self.get_workflow_api(workflow) second_task = workflow_api.next_task @@ -26,7 +26,7 @@ class TestValueExpression(BaseTest): workflow_api = self.get_workflow_api(workflow) first_task = workflow_api.next_task - self.complete_form(workflow_api, first_task, {'value_expression_value': 'black'}) + self.complete_form(workflow, first_task, {'value_expression_value': 'black'}) workflow_api = self.get_workflow_api(workflow) second_task = workflow_api.next_task