def test_target_is_nested_param(self): param = Parameter('Filters[0].Name', 'response') ignore_params = get_resource_ignore_params([param]) assert ignore_params == ['Filters'] param = Parameter('Filters[0].Values[0]', 'response') ignore_params = get_resource_ignore_params([param]) assert ignore_params == ['Filters']
def test_build_identifier_from_invalid_source_type(self): identifiers = [Parameter(target='Id', source='invalid')] parent = mock.Mock() params = {} response = {'Container': {'Frobs': []}} with pytest.raises(NotImplementedError): build_identifiers(identifiers, parent, params, response)
def test_build_identifier_from_parent_data_member(self): identifiers = [Parameter(target='Id', source='data', path='Member')] parent = mock.Mock() parent.meta = ResourceMeta('test', data={'Member': 'data-member'}) params = {} response = {'Container': {'Frobs': []}} values = build_identifiers(identifiers, parent, params, response) # Verify identifier loaded from responsePath scalar set assert values[0][1] == 'data-member'
def test_build_identifier_from_parent_data_member(self): identifiers = [Parameter(target='Id', source='data', path='Member')] parent = mock.Mock() parent.meta = ResourceMeta('test', data={'Member': 'data-member'}) params = {} response = {'Container': {'Frobs': []}} values = build_identifiers(identifiers, parent, params, response) self.assertEqual(values[0][1], 'data-member', 'Identifier loaded from parent data member not set')
def test_build_identifier_from_parent_identifier(self): identifiers = [Parameter(target='Id', source='identifier', name='Id')] parent = mock.Mock() parent.id = 'identifier' params = {} response = {'Container': {'Frobs': []}} values = build_identifiers(identifiers, parent, params, response) # Verify identifier loaded from responsePath scalar set assert values[0][1] == 'identifier'
def test_build_identifier_from_parent_identifier(self): identifiers = [Parameter(target='Id', source='identifier', name='Id')] parent = mock.Mock() parent.id = 'identifier' params = {} response = {'Container': {'Frobs': []}} values = build_identifiers(identifiers, parent, params, response) self.assertEqual(values[0][1], 'identifier', 'Identifier loaded from parent identifier not set')
def test_build_identifier_from_req_param(self): identifiers = [ Parameter(target='Id', source='requestParameter', path='Param') ] parent = mock.Mock() params = {'Param': 'request-param'} response = {'Container': {'Frobs': []}} values = build_identifiers(identifiers, parent, params, response) # Verify identifier loaded from responsePath scalar set assert values[0][1] == 'request-param'
def test_build_identifier_from_res_path_scalar(self): identifiers = [ Parameter(target='Id', source='response', path='Container.Frob.Id') ] parent = mock.Mock() params = {} response = {'Container': {'Frob': {'Id': 'response-path'}}} values = build_identifiers(identifiers, parent, params, response) # Verify identifier loaded from responsePath scalar set assert values[0][1] == 'response-path'
def test_build_identifier_from_req_param(self): identifiers = [ Parameter(target='Id', source='requestParameter', path='Param') ] parent = mock.Mock() params = {'Param': 'request-param'} response = {'Container': {'Frobs': []}} values = build_identifiers(identifiers, parent, params, response) self.assertEqual(values[0][1], 'request-param', 'Identifier loaded from request parameter not set')
def test_build_identifier_from_res_path_list(self): identifiers = [ Parameter(target='Id', source='response', path='Container.Frobs[].Id') ] parent = mock.Mock() params = {} response = {'Container': {'Frobs': [{'Id': 'response-path'}]}} values = build_identifiers(identifiers, parent, params, response) self.assertEqual(values[0][1], ['response-path'], 'Identifier loaded from responsePath list not set')
def test_target_is_element_of_multiple_resources(self): param = Parameter('InstanceIds[0]', 'response') ignore_params = get_resource_ignore_params([param]) assert ignore_params == ['InstanceIds']
def test_target_is_single_resource(self): param = Parameter('InstanceId', 'response') ignore_params = get_resource_ignore_params([param]) assert ignore_params == ['InstanceId']
def test_target_is_multiple_resources(self): param = Parameter('InstanceIds[]', 'response') ignore_params = get_resource_ignore_params([param]) self.assertEqual(ignore_params, ['InstanceIds'])