def fill(namespace=None, **requirements): requirements = { key: param.parametrize(current_param) for key, current_param in requirements.items()} def wrapper(context, **kwargs): kwargs.update( fill_function_call( fn, requirements, kwargs.get('activity'), context)) response = fn(**kwargs) if not response or not namespace: return response return namespace_result(response, namespace) update_wrapper(wrapper, fn) # Keep a record of the requirements value. This allows us to trim the # size of the context sent to the activity as an input. _link_decorator(fn, wrapper) _decorate( wrapper, 'requirements', param.get_all_requirements(requirements.values())) return wrapper
def fill(namespace=None, **requirements): requirements = { key: param.parametrize(current_param) for key, current_param in requirements.items() } def wrapper(context, **kwargs): kwargs.update( fill_function_call(fn, requirements, kwargs.get('activity'), context)) response = fn(**kwargs) if not response or not namespace: return response return namespace_result(response, namespace) update_wrapper(wrapper, fn) # Keep a record of the requirements value. This allows us to trim the # size of the context sent to the activity as an input. _link_decorator(fn, wrapper) _decorate(wrapper, 'requirements', param.get_all_requirements(requirements.values())) return wrapper
def test_all_requirements(): """Test getting all the requirements. """ keys = ['context.key1', 'context.key2', 'context.key3'] manual_keys = ['context.manual_key1', 'context.manual_key2'] params = [param.Param(key) for key in keys] params += manual_keys params += [param.StaticParam('Value')] params = [param.parametrize(current_param) for current_param in params] resp = param.get_all_requirements(params) for key in keys: assert key in resp for manual_key in manual_keys: assert manual_key in resp assert 'Value' not in resp