Updated new deref test
This commit is contained in:
		| @@ -789,35 +789,24 @@ class FieldTest(unittest.TestCase): | |||||||
|         class Person(Document): |         class Person(Document): | ||||||
|             name = StringField(max_length=250, required=True) |             name = StringField(max_length=250, required=True) | ||||||
|  |  | ||||||
|             meta = { "ordering" : "name" } |  | ||||||
|          |  | ||||||
|         class Room(Document): |         class Room(Document): | ||||||
|             number = StringField(max_length=250, required=True) |             number = StringField(max_length=250, required=True) | ||||||
|             staffs_with_position = ListField(DictField()) |             staffs_with_position = ListField(DictField()) | ||||||
|  |  | ||||||
|             meta = { "ordering" : "number" } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         Person.drop_collection() |         Person.drop_collection() | ||||||
|  |         Room.drop_collection() | ||||||
|  |  | ||||||
|         # 201 |  | ||||||
|         bob = Person.objects.create(name='Bob') |         bob = Person.objects.create(name='Bob') | ||||||
|         bob.save() |         bob.save() | ||||||
|         keven = Person.objects.create(name='Keven') |  | ||||||
|         keven.save() |  | ||||||
|         sarah = Person.objects.create(name='Sarah') |         sarah = Person.objects.create(name='Sarah') | ||||||
|         sarah.save() |         sarah.save() | ||||||
|  |  | ||||||
|         room_201 = Room.objects.create( number = "201") |         room_101 = Room.objects.create(number="101") | ||||||
|         room_201.staffs_with_position = [ {'position_key': 'window', 'staff' : sarah.to_dbref() }, |         room_101.staffs_with_position = [ | ||||||
|                                          { 'position_key': 'door', 'staff': bob.to_dbref() }, |             {'position_key': 'window', 'staff': sarah}, | ||||||
|                                          { 'position_key': 'center' , 'staff' : keven.to_dbref() } ] |             {'position_key': 'door', 'staff': bob.to_dbref()}] | ||||||
|         room_201.save() |         room_101.save() | ||||||
|  |  | ||||||
|         room = Room.objects.first().select_related() |         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) | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user