Add LazyReferenceField with dbref=True to embedded_document equality test
This commit is contained in:
parent
0d4e61d489
commit
68dc2925fb
@ -3322,6 +3322,7 @@ class TestInstance(MongoDBTestCase):
|
|||||||
def test_embedded_document_equality_with_lazy_ref(self):
|
def test_embedded_document_equality_with_lazy_ref(self):
|
||||||
class Job(EmbeddedDocument):
|
class Job(EmbeddedDocument):
|
||||||
boss = LazyReferenceField("Person")
|
boss = LazyReferenceField("Person")
|
||||||
|
boss_dbref = LazyReferenceField("Person", dbref=True)
|
||||||
|
|
||||||
class Person(Document):
|
class Person(Document):
|
||||||
job = EmbeddedDocumentField(Job)
|
job = EmbeddedDocumentField(Job)
|
||||||
@ -3329,7 +3330,7 @@ class TestInstance(MongoDBTestCase):
|
|||||||
Person.drop_collection()
|
Person.drop_collection()
|
||||||
|
|
||||||
boss = Person()
|
boss = Person()
|
||||||
worker = Person(job=Job(boss=boss))
|
worker = Person(job=Job(boss=boss, boss_dbref=boss))
|
||||||
boss.save()
|
boss.save()
|
||||||
worker.save()
|
worker.save()
|
||||||
|
|
||||||
@ -3341,15 +3342,15 @@ class TestInstance(MongoDBTestCase):
|
|||||||
|
|
||||||
# worker1.job should be equal to a newly created Job EmbeddedDocument
|
# worker1.job should be equal to a newly created Job EmbeddedDocument
|
||||||
# using either the Boss object or his ID.
|
# using either the Boss object or his ID.
|
||||||
self.assertEqual(worker1.job, Job(boss=boss))
|
self.assertEqual(worker1.job, Job(boss=boss, boss_dbref=boss))
|
||||||
self.assertEqual(worker1.job, Job(boss=boss.id))
|
self.assertEqual(worker1.job, Job(boss=boss.id, boss_dbref=boss.id))
|
||||||
|
|
||||||
# The above equalities should also hold after worker1.job.boss has been
|
# The above equalities should also hold after worker1.job.boss has been
|
||||||
# fetch()ed.
|
# fetch()ed.
|
||||||
worker1.job.boss.fetch()
|
worker1.job.boss.fetch()
|
||||||
self.assertEqual(worker1.job, worker.job)
|
self.assertEqual(worker1.job, worker.job)
|
||||||
self.assertEqual(worker1.job, Job(boss=boss))
|
self.assertEqual(worker1.job, Job(boss=boss, boss_dbref=boss))
|
||||||
self.assertEqual(worker1.job, Job(boss=boss.id))
|
self.assertEqual(worker1.job, Job(boss=boss.id, boss_dbref=boss.id))
|
||||||
|
|
||||||
def test_dbref_equality(self):
|
def test_dbref_equality(self):
|
||||||
class Test2(Document):
|
class Test2(Document):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user