Adds a test for a blind update append when the record doesn't exist yet

This commit is contained in:
Danny Cosson
2014-02-09 14:42:39 -05:00
parent 95d99bf359
commit b777f8cfc6

View File

@@ -125,3 +125,13 @@ class QueryUpdateTests(BaseCassEngTestCase):
partition=partition, cluster=cluster).update(text_set__add={'bar'})
obj = TestQueryUpdateModel.objects.get(partition=partition, cluster=cluster)
self.assertEqual(obj.text_set, {"foo", "bar"})
def test_set_add_updates_new_record(self):
""" If the key doesn't exist yet, an update creates the record
"""
partition = uuid4()
cluster = 1
TestQueryUpdateModel.objects(
partition=partition, cluster=cluster).update(text_set__add={'bar'})
obj = TestQueryUpdateModel.objects.get(partition=partition, cluster=cluster)
self.assertEqual(obj.text_set, {"bar"})