def test_fix_up_parameters_check_body(self): dummy_root_desc = {} no_payload_http_method = 'DELETE' with_payload_http_method = 'PUT' invalid_method_desc = {'response': 'Who cares'} valid_method_desc = {'request': {'key1': 'value1', 'key2': 'value2'}} parameters = _fix_up_parameters(invalid_method_desc, dummy_root_desc, no_payload_http_method) self.assertFalse('body' in parameters) parameters = _fix_up_parameters(valid_method_desc, dummy_root_desc, no_payload_http_method) self.assertFalse('body' in parameters) parameters = _fix_up_parameters(invalid_method_desc, dummy_root_desc, with_payload_http_method) self.assertFalse('body' in parameters) parameters = _fix_up_parameters(valid_method_desc, dummy_root_desc, with_payload_http_method) body = { 'description': 'The request body.', 'type': 'object', 'required': True, 'key1': 'value1', 'key2': 'value2', } self.assertEqual(parameters['body'], body)
def test_fix_up_parameters_check_body(self): dummy_root_desc = {} no_payload_http_method = "DELETE" with_payload_http_method = "PUT" invalid_method_desc = {"response": "Who cares"} valid_method_desc = {"request": {"key1": "value1", "key2": "value2"}} parameters = _fix_up_parameters(invalid_method_desc, dummy_root_desc, no_payload_http_method) self.assertFalse("body" in parameters) parameters = _fix_up_parameters(valid_method_desc, dummy_root_desc, no_payload_http_method) self.assertFalse("body" in parameters) parameters = _fix_up_parameters(invalid_method_desc, dummy_root_desc, with_payload_http_method) self.assertFalse("body" in parameters) parameters = _fix_up_parameters(valid_method_desc, dummy_root_desc, with_payload_http_method) body = { "description": "The request body.", "type": "object", "required": True, "key1": "value1", "key2": "value2", } self.assertEqual(parameters["body"], body)
def _base_fix_up_parameters_test(self, method_desc, http_method, root_desc): self.assertEqual(method_desc["httpMethod"], http_method) method_desc_copy = copy.deepcopy(method_desc) self.assertEqual(method_desc, method_desc_copy) parameters = _fix_up_parameters(method_desc_copy, root_desc, http_method) self.assertNotEqual(method_desc, method_desc_copy) for param_name in STACK_QUERY_PARAMETERS: self.assertEqual(STACK_QUERY_PARAMETER_DEFAULT_VALUE, parameters[param_name]) for param_name, value in root_desc.get("parameters", {}).items(): self.assertEqual(value, parameters[param_name]) return parameters
def _base_fix_up_parameters_test(self, method_desc, http_method, root_desc): self.assertEqual(method_desc['httpMethod'], http_method) method_desc_copy = copy.deepcopy(method_desc) self.assertEqual(method_desc, method_desc_copy) parameters = _fix_up_parameters(method_desc_copy, root_desc, http_method) self.assertNotEqual(method_desc, method_desc_copy) for param_name in STACK_QUERY_PARAMETERS: self.assertEqual(STACK_QUERY_PARAMETER_DEFAULT_VALUE, parameters[param_name]) for param_name, value in root_desc.get('parameters', {}).items(): self.assertEqual(value, parameters[param_name]) return parameters