Пример #1
0
    def test_pagination_delegates_to_paginator(self):
        paginator_cls = mock.Mock()
        service = mock.Mock()
        service.type = 'json'
        endpoint = mock.Mock()
        op = Operation(service, {'pagination': {'foo': 'bar'}}, paginator_cls)
        op.paginate(endpoint, foo='bar')

        paginator_cls.return_value.paginate.assert_called_with(endpoint,
                                                               foo='bar')
Пример #2
0
    def test_pagination_delegates_to_paginator(self):
        paginator_cls = mock.Mock()
        service = mock.Mock()
        service.type = 'json'
        endpoint = mock.Mock()
        op = Operation(service, {'pagination': {'foo': 'bar'}}, paginator_cls)
        op.paginate(endpoint, foo='bar')

        paginator_cls.return_value.paginate.assert_called_with(
            endpoint, foo='bar')
Пример #3
0
    def test_pagination_delegates_to_paginator(self):
        paginator_cls = mock.Mock()
        service = mock.Mock()
        service.type = 'json'
        endpoint = mock.Mock()
        op = Operation(service, {}, None, paginator_cls)
        op._load_pagination_config = mock.Mock()
        op._load_pagination_config.return_value = {
            'input_token': 'foo',
            'output_token': 'bar',
        }
        op.paginate(endpoint, foo='bar')

        paginator_cls.return_value.paginate.assert_called_with(
            endpoint, foo='bar')
Пример #4
0
    def test_pagination_delegates_to_paginator(self):
        paginator_cls = mock.Mock()
        service = mock.Mock()
        service.type = 'json'
        endpoint = mock.Mock()
        op = Operation(service, {}, None, paginator_cls)
        op._load_pagination_config = mock.Mock()
        op._load_pagination_config.return_value = {
            'input_token': 'foo',
            'output_token': 'bar',
        }
        op.paginate(endpoint, foo='bar')

        paginator_cls.return_value.paginate.assert_called_with(endpoint,
                                                               foo='bar')
Пример #5
0
 def test_exception_raised_when_cannot_paginate(self):
     op = Operation(None, {}, None)
     op._load_pagination_config = mock.Mock()
     op._load_pagination_config.side_effect = KeyError
     with self.assertRaises(TypeError):
         op.paginate(None)
Пример #6
0
 def test_can_paginate(self):
     op_data = {}
     op = Operation(None, op_data, None)
     op._load_pagination_config = mock.Mock()
     op._load_pagination_config.return_value = op_data
     self.assertTrue(op.can_paginate)
Пример #7
0
 def test_exception_raised_when_cannot_paginate(self):
     op = Operation(None, {})
     with self.assertRaises(TypeError):
         op.paginate(None)
Пример #8
0
 def test_can_paginate(self):
     op_data = {'pagination': {'foo': 'bar'}}
     op = Operation(None, op_data)
     self.assertTrue(op.can_paginate)
Пример #9
0
 def test_exception_raised_when_cannot_paginate(self):
     op = Operation(None, {})
     with self.assertRaises(TypeError):
         op.paginate(None)
Пример #10
0
 def test_exception_raised_when_cannot_paginate(self):
     op = Operation(None, {}, None)
     op._load_pagination_config = mock.Mock()
     op._load_pagination_config.side_effect = KeyError
     with self.assertRaises(TypeError):
         op.paginate(None)
Пример #11
0
 def test_can_paginate(self):
     op_data = {}
     op = Operation(None, op_data, None)
     op._load_pagination_config = mock.Mock()
     op._load_pagination_config.return_value = op_data
     self.assertTrue(op.can_paginate)