Skip to content

Commit

Permalink
fix test_delete_many_ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangs18 committed May 28, 2024
1 parent 957394e commit 3bfe573
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/MongoUtil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,23 @@ def test_delete_many_ok(self):
self.start_test()
mongo_util = self.getMongoUtil()
docs = mongo_util.handle_collection.find()
self.assertEqual(docs.count(), 10)
self.assertEqual(len(list(docs.clone())), 10)

docs_to_delete = list()
docs_to_delete.append(docs.next())
docs_to_delete.append(docs.next())
docs_to_delete = docs_to_delete * 2 # test delete duplicate items
deleted_count = mongo_util.delete_many(docs_to_delete)
self.assertEqual(deleted_count, 2)
self.assertEqual(mongo_util.handle_collection.find().count(), 8)
self.assertEqual(mongo_util.handle_collection.count_documents({}), 8)
docs = mongo_util.find_in([doc.get('hid') for doc in docs_to_delete], 'hid')
self.assertEqual(docs.count(), 0)
self.assertEqual(len(list(docs)), 0)

for doc in docs_to_delete:
try:
mongo_util.insert_one(doc)
except Exception:
pass
self.assertEqual(mongo_util.handle_collection.find().count(), 10)
self.assertEqual(mongo_util.handle_collection.count_documents({}), 10)
docs = mongo_util.find_in([doc.get('hid') for doc in docs_to_delete], 'hid')
self.assertEqual(docs.count(), 2)
self.assertEqual(len(list(docs)), 2)

0 comments on commit 3bfe573

Please sign in to comment.