def test_invalid_params(self):
     paginator = PagedPaginator()
     with pytest.raises(errors.InvalidPageFormat):
         paginator.paginate('foobar')
 def test_invalid_size_type(self):
     paginator = PagedPaginator()
     with pytest.raises(errors.InvalidPageValue) as exc_info:
         paginator.paginate({'size': 'foobar'})
     assert exc_info.value.detail == 'size must be an integer'
 def test_too_low_number_raises_error(self):
     paginator = PagedPaginator()
     with pytest.raises(errors.InvalidPageValue) as exc_info:
         paginator.paginate({'number': '0'})
     assert exc_info.value.detail == 'number must be at least 1'
 def test_too_high_size_raises_error(self):
     paginator = PagedPaginator()
     with pytest.raises(errors.InvalidPageValue) as exc_info:
         paginator.paginate({'size': '101'})
     assert exc_info.value.detail == (
         'size cannot exceed maximum page size of 100')
 def test_defaults(self):
     paginator = PagedPaginator()
     pagination = paginator.paginate({})
     assert pagination.number == 1
     assert pagination.size == 20
 def test_extra_parameters_raises_error(self):
     paginator = PagedPaginator()
     with pytest.raises(errors.InvalidPageParameter) as exc_info:
         paginator.paginate({'foo': 'bar'})
     assert exc_info.value.source_parameter == 'page[foo]'