• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.limited函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nova.api.openstack.common.limited函数的典型用法代码示例。如果您正苦于以下问题:Python limited函数的具体用法?Python limited怎么用?Python limited使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_limiter_offset_over_max

 def test_limiter_offset_over_max(self):
     # Test offset key works with a number over 1000 (max_limit).
     req = webob.Request.blank("/?offset=1001")
     self.assertEqual(0, len(common.limited(self.tiny, req)))
     self.assertEqual(0, len(common.limited(self.small, req)))
     self.assertEqual(0, len(common.limited(self.medium, req)))
     self.assertEqual(common.limited(self.large, req), self.large[1001:2001])
开发者ID:cyx1231st,项目名称:nova,代码行数:7,代码来源:test_common.py


示例2: test_limiter_limit_zero

 def test_limiter_limit_zero(self):
     """ Test limit of zero. """
     req = Request.blank("/?limit=0")
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium)
     self.assertEqual(common.limited(self.large, req), self.large[:1000])
开发者ID:rackerlabs,项目名称:reddwarf,代码行数:7,代码来源:test_common.py


示例3: test_limiter_limit_medium

 def test_limiter_limit_medium(self):
     # Test limit of 10.
     req = webob.Request.blank('/?limit=10')
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium[:10])
     self.assertEqual(common.limited(self.large, req), self.large[:10])
开发者ID:Charu-Sharma,项目名称:nova,代码行数:7,代码来源:test_common.py


示例4: test_limiter_nothing

 def test_limiter_nothing(self):
     """ Test request with no offset or limit """
     req = Request.blank("/")
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium)
     self.assertEqual(common.limited(self.large, req), self.large[:1000])
开发者ID:rackerlabs,项目名称:reddwarf,代码行数:7,代码来源:test_common.py


示例5: test_limiter_offset_zero

 def test_limiter_offset_zero(self):
     # Test offset key works with 0.
     req = webob.Request.blank('/?offset=0')
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium)
     self.assertEqual(common.limited(self.large, req), self.large[:1000])
开发者ID:Charu-Sharma,项目名称:nova,代码行数:7,代码来源:test_common.py


示例6: test_limiter_limit_medium

 def test_limiter_limit_medium(self):
     """ Test limit of 10. """
     req = Request.blank("/?limit=10")
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium[:10])
     self.assertEqual(common.limited(self.large, req), self.large[:10])
开发者ID:rackerlabs,项目名称:reddwarf,代码行数:7,代码来源:test_common.py


示例7: test_limiter_limit_over_max

 def test_limiter_limit_over_max(self):
     """ Test limit of 3000. """
     req = Request.blank('/?limit=3000')
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium)
     self.assertEqual(common.limited(self.large, req), self.large[:1000])
开发者ID:kavanista,项目名称:nova,代码行数:7,代码来源:test_common.py


示例8: test_limiter_offset_medium

 def test_limiter_offset_medium(self):
     # Test offset key works with a medium sized number.
     req = webob.Request.blank('/?offset=10')
     self.assertEqual(common.limited(self.tiny, req), [])
     self.assertEqual(common.limited(self.small, req), self.small[10:])
     self.assertEqual(common.limited(self.medium, req), self.medium[10:])
     self.assertEqual(common.limited(self.large, req), self.large[10:1010])
开发者ID:Charu-Sharma,项目名称:nova,代码行数:7,代码来源:test_common.py


示例9: test_limiter_nothing

 def test_limiter_nothing(self):
     # Test request with no offset or limit.
     req = webob.Request.blank('/')
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium)
     self.assertEqual(common.limited(self.large, req), self.large[:1000])
开发者ID:Charu-Sharma,项目名称:nova,代码行数:7,代码来源:test_common.py


示例10: test_limiter_limit_zero

 def test_limiter_limit_zero(self):
     # Test limit of zero.
     req = webob.Request.blank('/?limit=0')
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium)
     self.assertEqual(common.limited(self.large, req), self.large[:1000])
开发者ID:Charu-Sharma,项目名称:nova,代码行数:7,代码来源:test_common.py


示例11: test_limiter_limit_over_max

 def test_limiter_limit_over_max(self):
     # Test limit of 3000.
     req = webob.Request.blank("/?limit=3000")
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium)
     self.assertEqual(common.limited(self.large, req), self.large[:1000])
开发者ID:cyx1231st,项目名称:nova,代码行数:7,代码来源:test_common.py


示例12: test_limiter_offset_zero

 def test_limiter_offset_zero(self):
     """ Test offset key works with 0. """
     req = Request.blank("/?offset=0")
     self.assertEqual(common.limited(self.tiny, req), self.tiny)
     self.assertEqual(common.limited(self.small, req), self.small)
     self.assertEqual(common.limited(self.medium, req), self.medium)
     self.assertEqual(common.limited(self.large, req), self.large[:1000])
开发者ID:rackerlabs,项目名称:reddwarf,代码行数:7,代码来源:test_common.py


示例13: test_limiter_offset_over_max

 def test_limiter_offset_over_max(self):
     """ Test offset key works with a number over 1000 (max_limit). """
     req = Request.blank('/?offset=1001')
     self.assertEqual(common.limited(self.tiny, req), [])
     self.assertEqual(common.limited(self.small, req), [])
     self.assertEqual(common.limited(self.medium, req), [])
     self.assertEqual(
         common.limited(self.large, req), self.large[1001:2001])
开发者ID:kavanista,项目名称:nova,代码行数:8,代码来源:test_common.py


示例14: test_limiter_offset_bad

 def test_limiter_offset_bad(self):
     """
     Test offset key works with a BAD offset.
     """
     req = Request.blank(u'/?offset=\u0020aa')
     self.assertEqual(limited(self.tiny, req), self.tiny)
     self.assertEqual(limited(self.small, req), self.small)
     self.assertEqual(limited(self.medium, req), self.medium)
     self.assertEqual(limited(self.large, req), self.large[:1000])
开发者ID:yosh,项目名称:nova,代码行数:9,代码来源:test_common.py


示例15: test_limiter_custom_max_limit

 def test_limiter_custom_max_limit(self):
     """ Test a max_limit other than 1000. """
     items = range(2000)
     req = Request.blank("/?offset=1&limit=3")
     self.assertEqual(common.limited(items, req, max_limit=2000), items[1:4])
     req = Request.blank("/?offset=3&limit=0")
     self.assertEqual(common.limited(items, req, max_limit=2000), items[3:])
     req = Request.blank("/?offset=3&limit=2500")
     self.assertEqual(common.limited(items, req, max_limit=2000), items[3:])
     req = Request.blank("/?offset=3000&limit=10")
     self.assertEqual(common.limited(items, req, max_limit=2000), [])
开发者ID:rackerlabs,项目名称:reddwarf,代码行数:11,代码来源:test_common.py


示例16: test_limiter_limit_and_offset

 def test_limiter_limit_and_offset(self):
     """ Test request with both limit and offset. """
     items = range(2000)
     req = Request.blank("/?offset=1&limit=3")
     self.assertEqual(common.limited(items, req), items[1:4])
     req = Request.blank("/?offset=3&limit=0")
     self.assertEqual(common.limited(items, req), items[3:1003])
     req = Request.blank("/?offset=3&limit=1500")
     self.assertEqual(common.limited(items, req), items[3:1003])
     req = Request.blank("/?offset=3000&limit=10")
     self.assertEqual(common.limited(items, req), [])
开发者ID:rackerlabs,项目名称:reddwarf,代码行数:11,代码来源:test_common.py


示例17: test_limiter_limit_and_offset

 def test_limiter_limit_and_offset(self):
     # Test request with both limit and offset.
     items = range(2000)
     req = webob.Request.blank('/?offset=1&limit=3')
     self.assertEqual(common.limited(items, req), items[1:4])
     req = webob.Request.blank('/?offset=3&limit=0')
     self.assertEqual(common.limited(items, req), items[3:1003])
     req = webob.Request.blank('/?offset=3&limit=1500')
     self.assertEqual(common.limited(items, req), items[3:1003])
     req = webob.Request.blank('/?offset=3000&limit=10')
     self.assertEqual(common.limited(items, req), [])
开发者ID:Charu-Sharma,项目名称:nova,代码行数:11,代码来源:test_common.py


示例18: test_limiter_custom_max_limit

 def test_limiter_custom_max_limit(self):
     # Test a max_limit other than 1000.
     max_limit = 2000
     self.flags(osapi_max_limit=max_limit)
     items = range(max_limit)
     req = webob.Request.blank("/?offset=1&limit=3")
     self.assertEqual(common.limited(items, req), items[1:4])
     req = webob.Request.blank("/?offset=3&limit=0")
     self.assertEqual(common.limited(items, req), items[3:])
     req = webob.Request.blank("/?offset=3&limit=2500")
     self.assertEqual(common.limited(items, req), items[3:])
     req = webob.Request.blank("/?offset=3000&limit=10")
     self.assertEqual(0, len(common.limited(items, req)))
开发者ID:cyx1231st,项目名称:nova,代码行数:13,代码来源:test_common.py


示例19: test_limiter_custom_max_limit

 def test_limiter_custom_max_limit(self):
     # Test a max_limit other than 1000.
     items = range(2000)
     req = webob.Request.blank('/?offset=1&limit=3')
     self.assertEqual(
         common.limited(items, req, max_limit=2000), items[1:4])
     req = webob.Request.blank('/?offset=3&limit=0')
     self.assertEqual(
         common.limited(items, req, max_limit=2000), items[3:])
     req = webob.Request.blank('/?offset=3&limit=2500')
     self.assertEqual(
         common.limited(items, req, max_limit=2000), items[3:])
     req = webob.Request.blank('/?offset=3000&limit=10')
     self.assertEqual(common.limited(items, req, max_limit=2000), [])
开发者ID:Charu-Sharma,项目名称:nova,代码行数:14,代码来源:test_common.py


示例20: _get_cells

 def _get_cells(self, ctxt, req, detail=False):
     """Return all cells."""
     # Ask the CellsManager for the most recent data
     items = self.cells_rpcapi.get_cell_info_for_neighbors(ctxt)
     items = common.limited(items, req)
     items = [_scrub_cell(item, detail=detail) for item in items]
     return dict(cells=items)
开发者ID:dtroyer,项目名称:nova,代码行数:7,代码来源:cells.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.limited_by_marker函数代码示例发布时间:2022-05-27
下一篇:
Python common.get_sort_params函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap