Ejemplo n.º 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(
         self.conn, partition=partition, cluster=cluster, text_list=original
     )
     prepended = ["bar", "baz"]
     TestQueryUpdateModel.objects(partition=partition, cluster=cluster).update(
         self.conn, text_list__prepend=prepended
     )
     obj = TestQueryUpdateModel.objects.get(self.conn, partition=partition, cluster=cluster)
     expected = (prepended[::-1] if is_prepend_reversed() else prepended) + original
     self.assertEqual(obj.text_list, expected)
    def test_partial_updates(self):
        """ Tests that partial udpates work as expected """
        full = list(range(10))
        initial = full[3:7]

        m1 = TestListModel.create(self.conn, int_list=initial)

        m1.int_list = full
        m1.save(self.conn)

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

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