def get_args(self, cid=None, payload=None, param=None, data_format=None, is_required=None, default_value=None, path_prefix=None, use_text=None, channel_params=None, has_simple_io_config=None, bool_parameter_prefixes=None, int_parameters=None, int_parameter_suffixes=None, params_priority=None): return { 'cid': cid or new_cid(), 'payload': payload if payload is not None else { 'a': '1' }, 'param': param or Integer('a'), 'data_format': data_format or DATA_FORMAT.JSON, 'is_required': is_required or True, 'default_value': default_value or NO_DEFAULT_VALUE, 'path_prefix': path_prefix or 'request', 'use_text': use_text or True, 'channel_params': channel_params or {}, 'has_simple_io_config': has_simple_io_config or True, 'bool_parameter_prefixes': bool_parameter_prefixes or SIMPLE_IO.BOOL_PARAMETERS.SUFFIXES, 'int_parameters': int_parameters or SIMPLE_IO.INT_PARAMETERS.VALUES, 'int_parameter_suffixes': int_parameter_suffixes or SIMPLE_IO.INT_PARAMETERS.SUFFIXES, 'params_priority': params_priority or PARAMS_PRIORITY.MSG_OVER_CHANNEL_PARAMS, }
def test_convert_int_url_params_from_int(self): # Equivalent to # # GET /foo?item=1 # # Where 'item' is a required element (as int in channel_params). param_name = rand_string() value = rand_int() args = self.get_args(param=Integer(param_name), channel_params={param_name:value}, payload='') given_param_name, given_value = convert_param(**args) self.assertEquals(param_name, given_param_name) self.assertEquals(value, given_value)
def test_convert_int_payload_json_req_from_int(self): # Equivalent to # # POST /foo # {'item':1} # # Where 'item' is a required element. param_name = rand_string() value = rand_int() args = self.get_args(param=Integer(param_name), payload={param_name:value}) given_param_name, given_value = convert_param(**args) self.assertEquals(param_name, given_param_name) self.assertEquals(value, given_value)