Пример #1
0
    def test_count_queryset(self):
        for i in range(5):
            d = self.test_doc(a=str(i))
            yield from d.save()

        collection = self.test_doc._get_collection()

        qs = QuerySet(self.test_doc, collection)
        qs = qs.filter(a='1')
        count = yield from qs.count()
        self.assertEqual(count, 1)
Пример #2
0
    def test_to_list(self):
        futures = []
        for i in range(4):
            d = self.test_doc(a=str(i))
            futures.append(d.save())

        yield from asyncio.gather(*futures)
        collection = self.test_doc._collection
        qs = QuerySet(self.test_doc, collection)
        qs = qs.filter(a__in=['1', '2'])
        docs = yield from qs.to_list()
        self.assertEqual(len(docs), 2)
        self.assertTrue(isinstance(docs[0], self.test_doc))