Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Beany | N/A: Throw all the information out when encountering a Resour…

…ceConfilct.
  • Loading branch information...
commit 92f71e5a90fa800e2f45caffa448d95f9c9cb1ff 1 parent e5b0774
beany zou authored
View
1  .gitignore
@@ -4,4 +4,5 @@ dist
*.pyc
.coverage
xunit.xml
+build/
View
2  mangrove/datastore/database.py
@@ -208,7 +208,7 @@ def _save_document(self, document, modified=None):
result = self._save_documents([document], modified)[0]
# first item is success/failure
if not result[0]:
- raise FailedToSaveDataObject(result[1])
+ raise FailedToSaveDataObject(str(result))
# second item is doc ID
return result[1]
View
16 mangrove/datastore/tests/test_entity.py
@@ -5,7 +5,7 @@
from mangrove.datastore.entity import Entity, get_by_short_code, create_entity, get_all_entities, DataRecord, void_entity, get_by_short_code_include_voided
from mangrove.datastore.entity_type import define_type
from mangrove.datastore.tests.test_data import TestData
-from mangrove.errors.MangroveException import DataObjectAlreadyExists, EntityTypeDoesNotExistsException, DataObjectNotFound
+from mangrove.errors.MangroveException import DataObjectAlreadyExists, EntityTypeDoesNotExistsException, DataObjectNotFound, FailedToSaveDataObject
from mangrove.utils.test_utils.mangrove_test_case import MangroveTestCase
@@ -16,6 +16,20 @@ def test_create_entity(self):
self.assertTrue(uuid)
self.manager.delete(e)
+ def test_should_throw_excption_when_voiding_entity_which_has_been_updated_by_others(self):
+ e = Entity(self.manager, entity_type="clinic", location=["India", "MH", "Pune"])
+ uuid = e.save()
+ entity1 = self.manager.get(uuid, Entity)
+ entity2 = self.manager.get(uuid, Entity)
+
+ with self.assertRaises(FailedToSaveDataObject) as e:
+ entity1.void()
+ entity2.void()
+
+ self.assertTrue("ResourceConflict" in e.exception.message)
+
+ self.manager.delete(entity1)
+
def test_should_invalidate_entity(self):
short_code = "short_code"
entity_type = ["clinic"]
Please sign in to comment.
Something went wrong with that request. Please try again.