test around delete consistency #148

This commit is contained in:
Jon Haddad
2014-01-15 15:58:26 -08:00
parent 5a0f945294
commit 83d26c2f8d
2 changed files with 17 additions and 1 deletions

View File

@@ -513,7 +513,7 @@ class BaseModel(object):
def delete(self):
""" Deletes this instance """
self.__dmlquery__(self.__class__, self, batch=self._batch, timestamp=self._timestamp).delete()
self.__dmlquery__(self.__class__, self, batch=self._batch, timestamp=self._timestamp, consistency=self.__consistency__).delete()
def get_changed_columns(self):
""" returns a list of the columns that have been updated since instantiation or save """

View File

@@ -76,3 +76,19 @@ class TestConsistency(BaseConsistencyTest):
args = m.call_args
self.assertEqual(ALL, args[0][2])
def test_delete(self):
# ensures we always carry consistency through on delete statements
t = TestConsistencyModel.create(text="bacon and eggs")
t.text = "ham and cheese sandwich"
uid = t.id
with mock.patch.object(ConnectionPool, 'execute') as m:
t.consistency(ALL).delete()
with mock.patch.object(ConnectionPool, 'execute') as m:
TestConsistencyModel.objects(id=uid).consistency(ALL).delete()
args = m.call_args
self.assertEqual(ALL, args[0][2])