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')
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')
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')
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')
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)
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)
def test_exception_raised_when_cannot_paginate(self): op = Operation(None, {}) with self.assertRaises(TypeError): op.paginate(None)
def test_can_paginate(self): op_data = {'pagination': {'foo': 'bar'}} op = Operation(None, op_data) self.assertTrue(op.can_paginate)