本文整理汇总了Python中tastypie.paginator.Paginator.get_count方法的典型用法代码示例。如果您正苦于以下问题:Python Paginator.get_count方法的具体用法?Python Paginator.get_count怎么用?Python Paginator.get_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tastypie.paginator.Paginator
的用法示例。
在下文中一共展示了Paginator.get_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_page1
# 需要导入模块: from tastypie.paginator import Paginator [as 别名]
# 或者: from tastypie.paginator.Paginator import get_count [as 别名]
def test_page1(self):
reset_queries()
self.assertEqual(len(self._get_query_count()), 0)
paginator = Paginator({}, self.data_set, resource_uri='/api/v1/notes/', limit=2, offset=0)
# REGRESSION: Check to make sure only part of the cache is full.
# We used to run ``len()`` on the ``QuerySet``, which would populate
# the entire result set. Owwie.
paginator.get_count()
self.assertEqual(len(self._get_query_count()), 1)
# Should be nothing in the cache.
self.assertEqual(paginator.objects._result_cache, None)
meta = paginator.page()['meta']
self.assertEqual(meta['limit'], 2)
self.assertEqual(meta['offset'], 0)
self.assertEqual(meta['previous'], None)
self.assertEqual(meta['next'], '/api/v1/notes/?limit=2&offset=2')
self.assertEqual(meta['total_count'], 6)