Пример #1
0
    def test_get_with_multiple_docs(self):
        d = self.test_doc(a='a')
        yield from d.save()
        d = self.test_doc(a='a')
        yield from d.save()

        collection = self.test_doc._get_collection()
        qs = QuerySet(self.test_doc, collection)
        with self.assertRaises(self.test_doc.MultipleObjectsReturned):
            yield from qs.get(a='a')
Пример #2
0
    def test_get(self):
        d = self.test_doc(a=str(1))
        yield from d.save()
        dd = self.test_doc(a=str(2))
        yield from dd.save()
        collection = self.test_doc._collection
        qs = QuerySet(self.test_doc, collection)

        returned = yield from qs.get(id=d.id)
        self.assertEqual(d.id, returned.id)
Пример #3
0
    def test_get_with_no_doc(self):
        collection = self.test_doc._get_collection()
        qs = QuerySet(self.test_doc, collection)

        with self.assertRaises(self.test_doc.DoesNotExist):
            yield from qs.get(a='bla')