Calling reload on deleted / nonexistant documents raises DoesNotExist (#538)

This commit is contained in:
Ross Lawley
2014-01-24 14:10:55 +00:00
parent bc08bea284
commit 6d5e7d9e81
4 changed files with 34 additions and 3 deletions

View File

@@ -409,6 +409,27 @@ class InstanceTest(unittest.TestCase):
self.assertEqual(len(doc.embedded_field.list_field), 4)
self.assertEqual(len(doc.embedded_field.dict_field), 2)
def test_reload_doesnt_exist(self):
class Foo(Document):
pass
f = Foo()
try:
f.reload()
except Foo.DoesNotExist:
pass
except Exception as ex:
self.assertFalse("Threw wrong exception")
f.save()
f.delete()
try:
f.reload()
except Foo.DoesNotExist:
pass
except Exception as ex:
self.assertFalse("Threw wrong exception")
def test_dictionary_access(self):
"""Ensure that dictionary-style field access works properly.
"""