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