fix test
This commit is contained in:
parent
a1a93a4bdd
commit
26b70e9ed3
@ -884,9 +884,16 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
self.assertEqual(Blog.objects.count(), 2)
|
self.assertEqual(Blog.objects.count(), 2)
|
||||||
|
|
||||||
# test inserting an existing document (shouldn't be allowed)
|
# test inserting an existing document (shouldn't be allowed)
|
||||||
with self.assertRaises(OperationError):
|
with self.assertRaises(OperationError) as cm:
|
||||||
blog = Blog.objects.first()
|
blog = Blog.objects.first()
|
||||||
Blog.objects.insert(blog)
|
Blog.objects.insert(blog)
|
||||||
|
self.assertEqual(str(cm.exception), 'Some documents have ObjectIds use doc.update() instead')
|
||||||
|
|
||||||
|
# test inserting a query set
|
||||||
|
with self.assertRaises(OperationError) as cm:
|
||||||
|
blogs_qs = Blog.objects
|
||||||
|
Blog.objects.insert(blogs_qs)
|
||||||
|
self.assertEqual(str(cm.exception), 'Some documents have ObjectIds use doc.update() instead')
|
||||||
|
|
||||||
# insert 1 new doc
|
# insert 1 new doc
|
||||||
new_post = Blog(title="code123", id=ObjectId())
|
new_post = Blog(title="code123", id=ObjectId())
|
||||||
@ -939,12 +946,6 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
with self.assertRaises(OperationError):
|
with self.assertRaises(OperationError):
|
||||||
Blog.objects.insert({'name': 'garbage'})
|
Blog.objects.insert({'name': 'garbage'})
|
||||||
|
|
||||||
# test inserting a query set
|
|
||||||
with self.assertRaises(OperationError) as cm:
|
|
||||||
blogs_qs = Blog.objects
|
|
||||||
Blog.objects.insert(blogs_qs)
|
|
||||||
self.assertEqual(cm.exception.message, 'Some documents have ObjectIds use doc.update() instead')
|
|
||||||
|
|
||||||
def test_bulk_insert_update_input_document_ids(self):
|
def test_bulk_insert_update_input_document_ids(self):
|
||||||
class Comment(Document):
|
class Comment(Document):
|
||||||
idx = IntField()
|
idx = IntField()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user