当前位置: 首页>>代码示例>>Python>>正文


Python Paginator.limit方法代码示例

本文整理汇总了Python中tastypie.paginator.Paginator.limit方法的典型用法代码示例。如果您正苦于以下问题:Python Paginator.limit方法的具体用法?Python Paginator.limit怎么用?Python Paginator.limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tastypie.paginator.Paginator的用法示例。


在下文中一共展示了Paginator.limit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_limit

# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import 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)
开发者ID:3atmospheres,项目名称:django-tastypie,代码行数:19,代码来源:paginator.py

示例2: test_limit

# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import 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)
开发者ID:georgemarshall,项目名称:django-tastypie,代码行数:30,代码来源:paginator.py

示例3: test_limit

# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import 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
开发者ID:42ventures,项目名称:django-tastypie,代码行数:20,代码来源:paginator.py

示例4: test_limit

# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import 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)
开发者ID:SeanHayes,项目名称:django-tastypie,代码行数:42,代码来源:paginator.py

示例5: Paginator

# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import limit [as 别名]
        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)

        # Test the global max limit
        paginator = Paginator({}, self.data_set, limit=20, offset=0)
        settings.API_MAX_LIMIT_PER_PAGE = 10000
        paginator.limit = 20000
        self.assertEqual(paginator.get_limit(), 10000)

        # Test that if a limit is passed into the Paginator instance,
        #   it will defer to that
        paginator = Paginator({}, self.data_set, limit=20, offset=0, max_limit=10)
        paginator.limit = 20000
        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)
开发者ID:jasonbartz,项目名称:django-tastypie,代码行数:32,代码来源:paginator.py


注:本文中的tastypie.paginator.Paginator.limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。