예제 #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']
예제 #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)
예제 #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'
예제 #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')
예제 #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'
예제 #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')
예제 #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'
예제 #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'
예제 #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')
예제 #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')
예제 #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']
예제 #12
0
 def test_target_is_single_resource(self):
     param = Parameter('InstanceId', 'response')
     ignore_params = get_resource_ignore_params([param])
     assert ignore_params == ['InstanceId']
예제 #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'])