NotUniqueError gracefully replacing ambiguous OperationError when appropriate
This commit is contained in:
parent
eedf908770
commit
1c5e6a3425
4 changed files with 23 additions and 9 deletions
|
|
@ -1013,6 +1013,9 @@ class DocumentTest(unittest.TestCase):
|
|||
|
||||
# Two posts with the same slug is not allowed
|
||||
post2 = BlogPost(title='test2', slug='test')
|
||||
self.assertRaises(NotUniqueError, post2.save)
|
||||
|
||||
# Ensure backwards compatibilty for errors
|
||||
self.assertRaises(OperationError, post2.save)
|
||||
|
||||
def test_unique_with(self):
|
||||
|
|
@ -1063,7 +1066,7 @@ class DocumentTest(unittest.TestCase):
|
|||
|
||||
# Now there will be two docs with the same sub.slug
|
||||
post3 = BlogPost(title='test3', sub=SubDocument(year=2010, slug='test'))
|
||||
self.assertRaises(OperationError, post3.save)
|
||||
self.assertRaises(NotUniqueError, post3.save)
|
||||
|
||||
BlogPost.drop_collection()
|
||||
|
||||
|
|
@ -1090,11 +1093,11 @@ class DocumentTest(unittest.TestCase):
|
|||
|
||||
# Now there will be two docs with the same sub.slug
|
||||
post3 = BlogPost(title='test3', sub=SubDocument(year=2010, slug='test'))
|
||||
self.assertRaises(OperationError, post3.save)
|
||||
self.assertRaises(NotUniqueError, post3.save)
|
||||
|
||||
# Now there will be two docs with the same title and year
|
||||
post3 = BlogPost(title='test1', sub=SubDocument(year=2009, slug='test-1'))
|
||||
self.assertRaises(OperationError, post3.save)
|
||||
self.assertRaises(NotUniqueError, post3.save)
|
||||
|
||||
BlogPost.drop_collection()
|
||||
|
||||
|
|
@ -1117,7 +1120,7 @@ class DocumentTest(unittest.TestCase):
|
|||
try:
|
||||
cust_dupe.save()
|
||||
raise AssertionError, "We saved a dupe!"
|
||||
except OperationError:
|
||||
except NotUniqueError:
|
||||
pass
|
||||
Customer.drop_collection()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue