本文整理汇总了Python中eulexistdb.query.QuerySet.reset方法的典型用法代码示例。如果您正苦于以下问题:Python QuerySet.reset方法的具体用法?Python QuerySet.reset怎么用?Python QuerySet.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eulexistdb.query.QuerySet
的用法示例。
在下文中一共展示了QuerySet.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExistQueryTest
# 需要导入模块: from eulexistdb.query import QuerySet [as 别名]
# 或者: from eulexistdb.query.QuerySet import reset [as 别名]
#.........这里部分代码省略.........
item = self.qs.filter(name='one').only('document_name', 'collection_name').get()
path = '%s/%s' % (item.collection_name, item.document_name)
#
fqs = self.qs.filter(document_path=path, name='one')
self.assertEqual(1, fqs.count())
fqs = self.qs.filter(document_path=path, name='two')
self.assertEqual(0, fqs.count())
def test_get(self):
result = self.qs.get(contains="two")
self.assert_(isinstance(result, QueryTestModel), "get() with contains returns single result")
self.assertEqual(result.name, "two", "result returned by get() has correct data")
self.assertEqual(NUM_FIXTURES, self.qs.count(), "main queryset remains unchanged by filter")
def test_get_toomany(self):
self.assertRaises(ReturnedMultiple, self.qs.get, contains="one")
def test_get_nomatch(self):
self.assertRaises(DoesNotExist, self.qs.get, contains="fifty-four")
def test_get_byname(self):
result = self.qs.get(name="one")
self.assert_(isinstance(result, QueryTestModel), "get() with contains returns single result")
self.assertEqual(result.name, "one", "result returned by get() has correct data")
self.assertEqual(NUM_FIXTURES, self.qs.count(), "main queryset remains unchanged by filter")
def test_filter_get(self):
result = self.qs.filter(contains="one").filter(name="two").get()
self.assert_(isinstance(result, QueryTestModel))
self.assertEqual("two", result.name, "filtered get() returns correct data")
self.assertEqual(NUM_FIXTURES, self.qs.count(), "main queryset remains unchanged by filter")
def test_reset(self):
self.qs.filter(contains="two")
self.qs.reset()
self.assertEqual(NUM_FIXTURES, self.qs.count(), "main queryset remains unchanged by filter")
def test_order_by(self):
# element
fqs = self.qs.order_by('name')
self.assertEqual('four', fqs[0].name)
self.assertEqual('one', fqs[1].name)
self.assertEqual('three', fqs[2].name)
self.assertEqual('two', fqs[3].name)
self.assert_('order by ' not in self.qs.query.getQuery(), "main queryset unchanged by order_by()")
# attribute
fqs = self.qs.order_by('id')
self.assertEqual('abc', fqs[0].id)
self.assertEqual('def', fqs[1].id)
self.assertEqual('one', fqs[2].id)
self.assertEqual('xyz', fqs[3].id)
# reverse sorting
fqs = self.qs.order_by('-name')
self.assertEqual('four', fqs[3].name)
self.assertEqual('two', fqs[0].name)
fqs = self.qs.order_by('-id')
self.assertEqual('abc', fqs[3].id)
self.assertEqual('xyz', fqs[0].id)
# case-insensitive sorting - upper-case description should not sort first
fqs = self.qs.order_by('~description')
self.assert_(fqs[0].description.startswith('third'))
self.assert_(fqs[1].description.startswith('This one contains'))
# reverse case-insensitive sorting - flags in either order
fqs = self.qs.order_by('~-description')
self.assert_(fqs[3].description.startswith('third'))