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


Python common.limited函数代码示例

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


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


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