Ejemplo n.º 1
0
    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']
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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'
Ejemplo n.º 4
0
    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')
Ejemplo n.º 5
0
    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'
Ejemplo n.º 6
0
    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')
Ejemplo n.º 7
0
    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'
Ejemplo n.º 8
0
    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'
Ejemplo n.º 9
0
    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')
Ejemplo n.º 10
0
    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')
Ejemplo n.º 11
0
 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']
Ejemplo n.º 12
0
 def test_target_is_single_resource(self):
     param = Parameter('InstanceId', 'response')
     ignore_params = get_resource_ignore_params([param])
     assert ignore_params == ['InstanceId']
Ejemplo n.º 13
0
 def test_target_is_multiple_resources(self):
     param = Parameter('InstanceIds[]', 'response')
     ignore_params = get_resource_ignore_params([param])
     self.assertEqual(ignore_params, ['InstanceIds'])