def test_lock_is_not_acquireable___retry_esception_is_raised( self, pk, location, analysis_settings_path): with patch('fasteners.InterProcessLock.acquire', Mock(return_value=False)), \ patch('src.model_execution_worker.tasks.check_worker_lost', Mock(return_value='')), \ patch('src.model_execution_worker.tasks.notify_api_status') as api_notify: with self.assertRaises(Retry): start_analysis_task(pk, location, analysis_settings_path)
def test_lock_is_acquireable___start_analysis_is_ran( self, location, analysis_settings): with patch('src.model_execution_worker.tasks.start_analysis', Mock(return_value=True)) as start_analysis_mock: start_analysis_task.update_state = Mock() start_analysis_task(location, [analysis_settings]) start_analysis_task.update_state.assert_called_once_with( state=status.STATUS_RUNNING) start_analysis_mock.assert_called_once_with( analysis_settings, location)
def test_lock_is_acquireable___start_analysis_is_ran( self, location, analysis_settings_path): with patch('src.model_execution_worker.tasks.start_analysis', Mock(return_value=True)) as start_analysis_mock: start_analysis_task.update_state = Mock() start_analysis_task(location, analysis_settings_path) start_analysis_task.update_state.assert_called_once_with( state=status.STATUS_RUNNING) start_analysis_mock.assert_called_once_with( os.path.join(settings.get('worker', 'media_root'), analysis_settings_path), location, )
def test_lock_is_acquireable___start_analysis_is_ran( self, pk, location, analysis_settings_path): with patch('src.model_execution_worker.tasks.start_analysis', Mock(return_value=('', '', '', 0))) as start_analysis_mock, \ patch('src.model_execution_worker.tasks.check_worker_lost', Mock(return_value='')), \ patch('src.model_execution_worker.tasks.notify_api_status') as api_notify: start_analysis_task.update_state = Mock() start_analysis_task(pk, location, analysis_settings_path) api_notify.assert_called_once_with(pk, 'RUN_STARTED') start_analysis_task.update_state.assert_called_once_with( state=OASIS_TASK_STATUS["running"]["id"]) start_analysis_mock.assert_called_once_with( analysis_settings_path, location, complex_data_files=None)
def test_lock_is_acquireable___start_analysis_is_ran( self, location, analysis_settings_path): with patch('src.model_execution_worker.tasks.start_analysis', Mock(return_value=True)) as start_analysis_mock: start_analysis_task.update_state = Mock() start_analysis_task(location, analysis_settings_path) start_analysis_task.update_state.assert_called_once_with( state=OASIS_TASK_STATUS["running"]["id"]) start_analysis_mock.assert_called_once_with( os.path.join(settings.get('worker', 'media_root'), analysis_settings_path), location, complex_data_files=None)
def test_lock_is_not_acquireable___retry_esception_is_raised( self, location, analysis_settings): with patch('fasteners.InterProcessLock.acquire', Mock(return_value=False)): with self.assertRaises(Retry): start_analysis_task(location, [analysis_settings])