コード例 #1
0
 def test_list_prepend_updates(self):
     """ Prepend two things since order is reversed by default by CQL """
     partition = uuid4()
     cluster = 1
     original = ["foo"]
     TestQueryUpdateModel.objects.create(partition=partition, cluster=cluster, text_list=original)
     prepended = ["bar", "baz"]
     TestQueryUpdateModel.objects(partition=partition, cluster=cluster).update(text_list__prepend=prepended)
     obj = TestQueryUpdateModel.objects.get(partition=partition, cluster=cluster)
     expected = (prepended[::-1] if is_prepend_reversed() else prepended) + original
     self.assertEqual(obj.text_list, expected)
コード例 #2
0
 def test_list_prepend_updates(self):
     """ Prepend two things since order is reversed by default by CQL """
     partition = uuid4()
     cluster = 1
     original = ["foo"]
     TestQueryUpdateModel.objects.create(
             partition=partition, cluster=cluster, text_list=original)
     prepended = ['bar', 'baz']
     TestQueryUpdateModel.objects(
             partition=partition, cluster=cluster).update(
             text_list__prepend=prepended)
     obj = TestQueryUpdateModel.objects.get(partition=partition, cluster=cluster)
     expected = (prepended[::-1] if is_prepend_reversed() else prepended) + original
     self.assertEqual(obj.text_list, expected)
コード例 #3
0
    def test_partial_updates(self):
        """ Tests that partial udpates work as expected """
        full = list(range(10))
        initial = full[3:7]

        m1 = TestListModel.create(int_list=initial)

        m1.int_list = full
        m1.save()

        if is_prepend_reversed():
            expected = full[2::-1] + full[3:]
        else:
            expected = full

        m2 = TestListModel.get(partition=m1.partition)
        self.assertEqual(list(m2.int_list), expected)