def test_workflow_is_duplicate_returns_true_when_it_finds_workflow_with_same_hash_id( self, caplog): caplog.set_level(logging.INFO) test_igniter = igniter.Igniter(self.config_path) assert ( test_igniter.workflow_is_duplicate(workflow=queue_handler.Workflow( 'fake_workflow_id', labels={'hash-id': ''})) is True)
def test_workflow_is_duplicate_returns_false_when_it_only_finds_input_workflow( self, caplog): caplog.set_level(logging.INFO) test_igniter = igniter.Igniter(self.config_path) assert ( test_igniter.workflow_is_duplicate(workflow=queue_handler.Workflow( 'fake_workflow_id', labels={'hash-id': ''})) is False)
def test_release_workflow_successfully_releases_a_workflow(self, caplog): """ This function asserts the `igniter.release_workflow()` can work properly when it gets 200 OK from the Cromwell. """ caplog.set_level(logging.INFO) test_igniter = igniter.Igniter(self.config_path) test_igniter.release_workflow(self.mock_workflow) info = caplog.text assert 'Released a workflow fake_workflow_id' in info
def test_release_workflow_handles_requests_exception(self, caplog): """ This function asserts the `igniter.release_workflow()` can work properly when it runs into requests exceptions when talking to Cromwell. """ caplog.set_level(logging.ERROR) test_igniter = igniter.Igniter(self.config_path) test_igniter.release_workflow(self.mock_workflow) error = caplog.text assert 'Failed to release a workflow fake_workflow_id' in error
def test_release_workflow_handles_500_response_code(self, caplog): """ This function asserts the `igniter.release_workflow()` can work properly when it gets 500 error from the Cromwell. """ caplog.set_level(logging.WARNING) test_igniter = igniter.Igniter(self.config_path) test_igniter.release_workflow(self.mock_workflow) warn = caplog.text assert 'Failed to release a workflow fake_workflow_id' in warn
def execution_event_with_mocks( self, workflow, release_calls, abort_calls, is_dupe_return=None, is_dupe_effect=None, ): mock_handler = self.setup_queue_handler(workflow=workflow) test_igniter = igniter.Igniter(self.config_path) test_igniter.workflow_is_duplicate = mock.Mock( return_value=is_dupe_return, side_effect=is_dupe_effect) test_igniter.release_workflow = mock.Mock() test_igniter.abort_workflow = mock.Mock() test_igniter.execution_event(mock_handler) assert test_igniter.release_workflow.call_count is release_calls assert test_igniter.abort_workflow.call_count is abort_calls
def test_execution_event_sleeps_properly_for_empty_queue(self, caplog): """ This function asserts the `igniter.execution_event()` goes back to sleep when there is no available entry in the queue to be processed. """ caplog.set_level(logging.INFO) mock_handler = self.setup_queue_handler() assert mock_handler.workflow_queue.empty() is True test_igniter = igniter.Igniter(self.config_path) test_igniter.workflow_start_interval = 1 start = timeit.default_timer() test_igniter.execution_event(mock_handler) stop = timeit.default_timer() elapsed = stop - start info = caplog.text assert ( 'The in-memory queue is empty, go back to sleep and wait for the handler to retrieve workflows.' in info) assert (test_igniter.workflow_start_interval <= elapsed <= test_igniter.workflow_start_interval * 1.5)