Fixing delta bug for dict fields

This commit is contained in:
Ross Lawley
2011-07-29 15:48:29 +01:00
parent e3cbeb9df0
commit 3f3f93b0fa
3 changed files with 24 additions and 6 deletions

View File

@@ -1504,6 +1504,18 @@ class DocumentTest(unittest.TestCase):
del(doc.embedded_field.list_field[2].list_field)
self.assertEquals(doc._delta(), ({}, {'embedded_field.list_field.2.list_field': 1}))
doc.save()
doc.reload()
doc.dict_field['Embedded'] = embedded_1
doc.save()
doc.reload()
doc.dict_field['Embedded'].string_field = 'Hello World'
self.assertEquals(doc._get_changed_fields(), ['dict_field.Embedded.string_field'])
self.assertEquals(doc._delta(), ({'dict_field.Embedded.string_field': 'Hello World'}, {}))
def test_delta_db_field(self):
class Doc(Document):
@@ -1795,7 +1807,8 @@ class DocumentTest(unittest.TestCase):
person.save()
person = self.Person.objects.get()
self.assertTrue(person.comments_dict['first_post'].published)
self.assertFalse(person.comments_dict['first_post'].published)
def test_delete(self):
"""Ensure that document may be deleted using the delete method.
"""