@contextmanager
def simulate_running_pipeline(pipeline_target, backend, email=None, fullname=None, username=None):
 pipeline_data = {'backend': backend, 'kwargs': {'details': {}}}
 if (email is not None):
  pipeline_data['kwargs']['details']['email'] = email
 if (fullname is not None):
  pipeline_data['kwargs']['details']['fullname'] = fullname
 if (username is not None):
  pipeline_data['kwargs']['username'] = username
 pipeline_get = mock.patch('{pipeline}.get'.format(pipeline=pipeline_target), spec=True)
 pipeline_running = mock.patch('{pipeline}.running'.format(pipeline=pipeline_target), spec=True)
 mock_get = pipeline_get.start()
 mock_running = pipeline_running.start()
 mock_get.return_value = pipeline_data
 mock_running.return_value = True
 try:
  (yield)
 finally:
  pipeline_get.stop()
  pipeline_running.stop()

@ contextmanager def simulate_running_pipeline ( pipeline_target , backend , email = None , fullname = None , username = None ) : pipeline_data = { 'backend' : backend , 'kwargs' : { 'details' : { } } } if ( email is not None ) : pipeline_data [ 'kwargs' ] [ 'details' ] [ 'email' ] = email if ( fullname is not None ) : pipeline_data [ 'kwargs' ] [ 'details' ] [ 'fullname' ] = fullname if ( username is not None ) : pipeline_data [ 'kwargs' ] [ 'username' ] = username pipeline_get = mock . patch ( '{pipeline}.get' . format ( pipeline = pipeline_target ) , spec = True ) pipeline_running = mock . patch ( '{pipeline}.running' . format ( pipeline = pipeline_target ) , spec = True ) mock_get = pipeline_get . start ( ) mock_running = pipeline_running . start ( ) mock_get . return_value = pipeline_data mock_running . return_value = True try : ( yield ) finally : pipeline_get . stop ( ) pipeline_running . stop ( )
simulate that a pipeline is currently running .