Conditional test around C* list prepend bug, which is not in 1.2.x

This commit is contained in:
Adam Holmberg
2015-03-19 11:56:27 -05:00
parent fa2e4c77e9
commit 82df9cf075
3 changed files with 28 additions and 12 deletions

View File

@@ -18,7 +18,7 @@ import warnings
from cassandra.cqlengine import connection
from cassandra.cqlengine.management import create_keyspace_simple, CQLENG_ALLOW_SCHEMA_MANAGEMENT
from tests.integration import use_single_node, PROTOCOL_VERSION
from tests.integration import get_server_versions, use_single_node, PROTOCOL_VERSION
def setup_package():
@@ -29,7 +29,13 @@ def setup_package():
keyspace = 'cqlengine_test'
connection.setup(['localhost'],
protocol_version=PROTOCOL_VERSION,
default_keyspace=keyspace)
protocol_version=PROTOCOL_VERSION,
default_keyspace=keyspace)
create_keyspace_simple(keyspace, 1)
def is_prepend_reversed():
# do we have https://issues.apache.org/jira/browse/CASSANDRA-8733 ?
ver, _ = get_server_versions()
return not (ver >= (2, 0, 13) or ver >= (2, 1, 3))

View File

@@ -20,6 +20,7 @@ import six
from cassandra.cqlengine.models import Model, ValidationError
import cassandra.cqlengine.columns as columns
from cassandra.cqlengine.management import sync_table, drop_table
from tests.integration.cqlengine import is_prepend_reversed
from tests.integration.cqlengine.base import BaseCassEngTestCase
@@ -240,15 +241,21 @@ class TestListColumn(BaseCassEngTestCase):
def test_partial_updates(self):
""" Tests that partial udpates work as expected """
final = list(range(10))
initial = final[3:7]
full = list(range(10))
initial = full[3:7]
m1 = TestListModel.create(int_list=initial)
m1.int_list = final
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)
assert list(m2.int_list) == final
self.assertEqual(list(m2.int_list), expected)
def test_instantiation_with_column_class(self):
"""

View File

@@ -14,12 +14,12 @@
from uuid import uuid4
from cassandra.cqlengine import ValidationError
from cassandra.cqlengine.query import QueryException
from tests.integration.cqlengine.base import BaseCassEngTestCase
from cassandra.cqlengine.models import Model
from cassandra.cqlengine.management import sync_table, drop_table
from cassandra.cqlengine import columns
from tests.integration.cqlengine import is_prepend_reversed
from tests.integration.cqlengine.base import BaseCassEngTestCase
class TestQueryUpdateModel(Model):
@@ -192,13 +192,16 @@ class QueryUpdateTests(BaseCassEngTestCase):
""" 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=["foo"])
partition=partition, cluster=cluster, text_list=original)
prepended = ['bar', 'baz']
TestQueryUpdateModel.objects(
partition=partition, cluster=cluster).update(
text_list__prepend=['bar', 'baz'])
text_list__prepend=prepended)
obj = TestQueryUpdateModel.objects.get(partition=partition, cluster=cluster)
self.assertEqual(obj.text_list, ["bar", "baz", "foo"])
expected = (prepended[::-1] if is_prepend_reversed() else prepended) + original
self.assertEqual(obj.text_list, expected)
def test_map_update_updates(self):
""" Merge a dictionary into existing value """