本文整理汇总了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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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])
示例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), [])