Merge branch 'pr-622'
This commit is contained in:
@@ -79,8 +79,8 @@ class ModelUpdateTests(BaseCassEngTestCase):
|
|||||||
self.assertEqual(m2.count, m1.count)
|
self.assertEqual(m2.count, m1.count)
|
||||||
self.assertEqual(m2.text, m0.text)
|
self.assertEqual(m2.text, m0.text)
|
||||||
|
|
||||||
def test_noop_model_update(self):
|
def test_noop_model_direct_update(self):
|
||||||
""" tests that calling update on a model with no changes will do nothing. """
|
""" Tests that calling update on a model with no changes will do nothing. """
|
||||||
m0 = TestUpdateModel.create(count=5, text='monkey')
|
m0 = TestUpdateModel.create(count=5, text='monkey')
|
||||||
|
|
||||||
with patch.object(self.session, 'execute') as execute:
|
with patch.object(self.session, 'execute') as execute:
|
||||||
@@ -91,6 +91,38 @@ class ModelUpdateTests(BaseCassEngTestCase):
|
|||||||
m0.update(count=5)
|
m0.update(count=5)
|
||||||
assert execute.call_count == 0
|
assert execute.call_count == 0
|
||||||
|
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
m0.update(partition=m0.partition)
|
||||||
|
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
m0.update(cluster=m0.cluster)
|
||||||
|
|
||||||
|
def test_noop_model_assignation_update(self):
|
||||||
|
""" Tests that assigning the same value on a model will do nothing. """
|
||||||
|
# Create object and fetch it back to eliminate any hidden variable
|
||||||
|
# cache effect.
|
||||||
|
m0 = TestUpdateModel.create(count=5, text='monkey')
|
||||||
|
m1 = TestUpdateModel.get(partition=m0.partition, cluster=m0.cluster)
|
||||||
|
|
||||||
|
with patch.object(self.session, 'execute') as execute:
|
||||||
|
m1.save()
|
||||||
|
assert execute.call_count == 0
|
||||||
|
|
||||||
|
with patch.object(self.session, 'execute') as execute:
|
||||||
|
m1.count = 5
|
||||||
|
m1.save()
|
||||||
|
assert execute.call_count == 0
|
||||||
|
|
||||||
|
with patch.object(self.session, 'execute') as execute:
|
||||||
|
m1.partition = m0.partition
|
||||||
|
m1.save()
|
||||||
|
assert execute.call_count == 0
|
||||||
|
|
||||||
|
with patch.object(self.session, 'execute') as execute:
|
||||||
|
m1.cluster = m0.cluster
|
||||||
|
m1.save()
|
||||||
|
assert execute.call_count == 0
|
||||||
|
|
||||||
def test_invalid_update_kwarg(self):
|
def test_invalid_update_kwarg(self):
|
||||||
""" tests that passing in a kwarg to the update method that isn't a column will fail """
|
""" tests that passing in a kwarg to the update method that isn't a column will fail """
|
||||||
m0 = TestUpdateModel.create(count=5, text='monkey')
|
m0 = TestUpdateModel.create(count=5, text='monkey')
|
||||||
|
|||||||
Reference in New Issue
Block a user