コード例 #1
0
 def test_invalid_params(self):
     paginator = PagedPaginator()
     with pytest.raises(errors.InvalidPageFormat):
         paginator.paginate('foobar')
コード例 #2
0
 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'
コード例 #3
0
 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'
コード例 #4
0
 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')
コード例 #5
0
 def test_defaults(self):
     paginator = PagedPaginator()
     pagination = paginator.paginate({})
     assert pagination.number == 1
     assert pagination.size == 20
コード例 #6
0
 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]'