Updated new deref test
This commit is contained in:
parent
398fd4a548
commit
5a1eaa0a98
@ -783,41 +783,30 @@ class FieldTest(unittest.TestCase):
|
||||
root = root.reload()
|
||||
self.assertEquals(root.children, [company])
|
||||
self.assertEquals(company.parents, [root])
|
||||
|
||||
|
||||
def test_dict_in_dbref_instance(self):
|
||||
|
||||
class Person(Document):
|
||||
name = StringField(max_length=250, required=True)
|
||||
|
||||
meta = { "ordering" : "name" }
|
||||
|
||||
class Room(Document):
|
||||
number = StringField(max_length=250, required=True)
|
||||
staffs_with_position = ListField(DictField())
|
||||
|
||||
meta = { "ordering" : "number" }
|
||||
|
||||
|
||||
|
||||
Person.drop_collection()
|
||||
Room.drop_collection()
|
||||
|
||||
# 201
|
||||
bob = Person.objects.create(name='Bob')
|
||||
bob.save()
|
||||
keven = Person.objects.create(name='Keven')
|
||||
keven.save()
|
||||
sarah = Person.objects.create(name='Sarah')
|
||||
sarah.save()
|
||||
|
||||
room_201 = Room.objects.create( number = "201")
|
||||
room_201.staffs_with_position = [ {'position_key': 'window', 'staff' : sarah.to_dbref() },
|
||||
{ 'position_key': 'door', 'staff': bob.to_dbref() },
|
||||
{ 'position_key': 'center' , 'staff' : keven.to_dbref() } ]
|
||||
room_201.save()
|
||||
room_101 = Room.objects.create(number="101")
|
||||
room_101.staffs_with_position = [
|
||||
{'position_key': 'window', 'staff': sarah},
|
||||
{'position_key': 'door', 'staff': bob.to_dbref()}]
|
||||
room_101.save()
|
||||
|
||||
room = Room.objects.first().select_related()
|
||||
room.to_mongo()
|
||||
|
||||
|
||||
|
||||
|
||||
self.assertEquals(room.staffs_with_position[0]['staff'], sarah)
|
||||
self.assertEquals(room.staffs_with_position[1]['staff'], bob)
|
||||
|
Loading…
x
Reference in New Issue
Block a user