query_counter fix

This commit is contained in:
Erdenezul Batmunkh 2018-05-21 10:04:59 +08:00
parent 6fb5c312c3
commit 9bd328e147

View File

@ -967,18 +967,10 @@ class QuerySetTest(unittest.TestCase):
org.save() org.save()
self.assertEqual(q, 0) self.assertEqual(q, 0)
# get MongoDB version info
connection = get_connection()
info = connection.test.command('buildInfo')
mongodb_version = tuple([int(i) for i in info['version'].split('.')])
org = Organization.objects.get(id=o1.id) org = Organization.objects.get(id=o1.id)
with query_counter() as q: with query_counter() as q:
org.save(cascade=False) org.save(cascade=False)
if mongodb_version >= (3, 0): self.assertEqual(q, 0)
self.assertEqual(q, 1)
else:
self.assertEqual(q, 0)
# Saving a doc after you append a reference to it should result in # Saving a doc after you append a reference to it should result in
# two db operations (a query for the reference and an update). # two db operations (a query for the reference and an update).