Improve minor things in the tests

This commit is contained in:
Bastien Gérard
2019-05-26 22:17:58 +02:00
parent 24ba35d76f
commit 6e1c132ee8
5 changed files with 27 additions and 27 deletions

View File

@@ -3204,7 +3204,7 @@ class InstanceTest(MongoDBTestCase):
p2.name = 'alon2'
p2.save()
p3 = Person.objects().only('created_on')[0]
self.assertEquals(orig_created_on, p3.created_on)
self.assertEqual(orig_created_on, p3.created_on)
class Person(Document):
created_on = DateTimeField(default=lambda: datetime.utcnow())
@@ -3213,10 +3213,10 @@ class InstanceTest(MongoDBTestCase):
p4 = Person.objects()[0]
p4.save()
self.assertEquals(p4.height, 189)
self.assertEqual(p4.height, 189)
# However the default will not be fixed in DB
self.assertEquals(Person.objects(height=189).count(), 0)
self.assertEqual(Person.objects(height=189).count(), 0)
# alter DB for the new default
coll = Person._get_collection()
@@ -3224,17 +3224,17 @@ class InstanceTest(MongoDBTestCase):
if 'height' not in person:
coll.update_one({'_id': person['_id']}, {'$set': {'height': 189}})
self.assertEquals(Person.objects(height=189).count(), 1)
self.assertEqual(Person.objects(height=189).count(), 1)
def test_from_son(self):
# 771
class MyPerson(self.Person):
meta = dict(shard_key=["id"])
p = MyPerson.from_json('{"name": "name", "age": 27}', created=True)
self.assertEquals(p.id, None)
self.assertEqual(p.id, None)
p.id = "12345" # in case it is not working: "OperationError: Shard Keys are immutable..." will be raised here
p = MyPerson._from_son({"name": "name", "age": 27}, created=True)
self.assertEquals(p.id, None)
self.assertEqual(p.id, None)
p.id = "12345" # in case it is not working: "OperationError: Shard Keys are immutable..." will be raised here
def test_from_son_created_False_without_id(self):
@@ -3312,7 +3312,7 @@ class InstanceTest(MongoDBTestCase):
u_from_db = User.objects.get(name='user')
u_from_db.height = None
u_from_db.save()
self.assertEquals(u_from_db.height, None)
self.assertEqual(u_from_db.height, None)
# 864
self.assertEqual(u_from_db.str_fld, None)
self.assertEqual(u_from_db.int_fld, None)
@@ -3326,7 +3326,7 @@ class InstanceTest(MongoDBTestCase):
u.save()
User.objects(name='user').update_one(set__height=None, upsert=True)
u_from_db = User.objects.get(name='user')
self.assertEquals(u_from_db.height, None)
self.assertEqual(u_from_db.height, None)
def test_not_saved_eq(self):
"""Ensure we can compare documents not saved.