本文整理汇总了Python中tastypie.paginator.Paginator.offset方法的典型用法代码示例。如果您正苦于以下问题:Python Paginator.offset方法的具体用法?Python Paginator.offset怎么用?Python Paginator.offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tastypie.paginator.Paginator
的用法示例。
在下文中一共展示了Paginator.offset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_offset
# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import offset [as 别名]
def test_offset(self):
paginator = Paginator({}, self.data_set, limit=20, offset=0)
paginator.offset = '10'
self.assertEqual(paginator.get_offset(), 10)
paginator.offset = 0
self.assertEqual(paginator.get_offset(), 0)
paginator.offset = 10
self.assertEqual(paginator.get_offset(), 10)
paginator.offset = -10
raised = False
try:
paginator.get_offset()
except BadRequest as e:
raised = e
self.assertTrue(raised)
self.assertEqual(str(raised), "Invalid offset '-10' provided. Please provide a positive integer >= 0.")
paginator.offset = 'hAI!'
raised = False
try:
paginator.get_offset()
except BadRequest as e:
raised = e
self.assertTrue(raised)
self.assertEqual(str(raised), "Invalid offset 'hAI!' provided. Please provide an integer.")
示例2: test_offset
# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import offset [as 别名]
def test_offset(self):
paginator = Paginator({}, self.data_set, limit=20, offset=0)
paginator.offset = '10'
self.assertEqual(paginator.get_offset(), 10)
paginator.offset = 0
self.assertEqual(paginator.get_offset(), 0)
paginator.offset = 10
self.assertEqual(paginator.get_offset(), 10)
paginator.offset= -10
self.assertRaises(BadRequest, paginator.get_offset)
paginator.offset = 'hAI!'
self.assertRaises(BadRequest, paginator.get_offset)
示例3: test_offset
# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import offset [as 别名]
def test_offset(self):
paginator = Paginator({}, self.data_set, limit=20, offset=0)
paginator.offset = '10'
self.assertEqual(paginator.get_offset(), 10)
paginator.offset = 0
self.assertEqual(paginator.get_offset(), 0)
paginator.offset = 10
self.assertEqual(paginator.get_offset(), 10)
paginator.offset= -10
raised = False
try:
paginator.get_offset()
except BadRequest, e:
raised = e
示例4: test_offset
# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import offset [as 别名]
def test_offset(self):
request = QueryDict('', mutable=True)
paginator = Paginator(request, self.data_set, limit=20, offset=0)
paginator.offset = '10'
self.assertEqual(paginator.get_offset(), 10)
paginator.offset = 0
self.assertEqual(paginator.get_offset(), 0)
paginator.offset = 10
self.assertEqual(paginator.get_offset(), 10)
paginator.offset = -10
self.assertRaises(BadRequest, paginator.get_offset)
paginator.offset = 'hAI!'
self.assertRaises(BadRequest, paginator.get_offset)
示例5: test_regression_nonqueryset
# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import offset [as 别名]
paginator.offset = 0
self.assertEqual(paginator.get_offset(), 0)
paginator.offset = 10
self.assertEqual(paginator.get_offset(), 10)
paginator.offset= -10
raised = False
try:
paginator.get_offset()
except BadRequest, e:
raised = e
self.assertTrue(raised)
self.assertEqual(str(raised), "Invalid offset '-10' provided. Please provide a positive integer >= 0.")
paginator.offset = 'hAI!'
raised = False
try:
paginator.get_offset()
except BadRequest, e:
raised = e
self.assertTrue(raised)
self.assertEqual(str(raised), "Invalid offset 'hAI!' provided. Please provide an integer.")
def test_regression_nonqueryset(self):
paginator = Paginator({}, ['foo', 'bar', 'baz'], limit=2, offset=0)
# This would fail due to ``count`` being present on ``list`` but called
# differently.
page = paginator.page()
self.assertEqual(page['objects'], ['foo', 'bar'])
示例6: test_regression_nonqueryset
# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import offset [as 别名]
paginator.offset = 0
self.assertEqual(paginator.get_offset(), 0)
paginator.offset = 10
self.assertEqual(paginator.get_offset(), 10)
paginator.offset = -10
raised = False
try:
paginator.get_offset()
except BadRequest, e:
raised = e
self.assertTrue(raised)
self.assertEqual(str(raised), "Invalid offset '-10' provided. Please provide a positive integer >= 0.")
paginator.offset = "hAI!"
raised = False
try:
paginator.get_offset()
except BadRequest, e:
raised = e
self.assertTrue(raised)
self.assertEqual(str(raised), "Invalid offset 'hAI!' provided. Please provide an integer.")
def test_regression_nonqueryset(self):
paginator = Paginator({}, ["foo", "bar", "baz"], limit=2, offset=0)
# This would fail due to ``count`` being present on ``list`` but called
# differently.
page = paginator.page()
self.assertEqual(page["objects"], ["foo", "bar"])