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


Python Paginator.offset方法代码示例

本文整理汇总了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.")
开发者ID:SeanHayes,项目名称:django-tastypie,代码行数:31,代码来源:paginator.py

示例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)
开发者ID:3atmospheres,项目名称:django-tastypie,代码行数:19,代码来源:paginator.py

示例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
开发者ID:42ventures,项目名称:django-tastypie,代码行数:20,代码来源:paginator.py

示例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)
开发者ID:georgemarshall,项目名称:django-tastypie,代码行数:20,代码来源:paginator.py

示例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'])
开发者ID:42ventures,项目名称:django-tastypie,代码行数:32,代码来源:paginator.py

示例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"])
开发者ID:Bahus,项目名称:django-tastypie,代码行数:32,代码来源:paginator.py


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