Merge pull request #355 from kishkaru/cqlengine_fix
Cqlengine fixes to skip tests properly
This commit is contained in:
@@ -153,14 +153,19 @@ class TestDate(BaseCassEngTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if PROTOCOL_VERSION < 4:
|
||||
raise unittest.SkipTest("Protocol v4 datatypes require native protocol 4+, currently using: {0}".format(PROTOCOL_VERSION))
|
||||
|
||||
return
|
||||
sync_table(cls.DateTest)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if PROTOCOL_VERSION < 4:
|
||||
return
|
||||
drop_table(cls.DateTest)
|
||||
|
||||
def setUp(self):
|
||||
if PROTOCOL_VERSION < 4:
|
||||
raise unittest.SkipTest("Protocol v4 datatypes require native protocol 4+, currently using: {0}".format(PROTOCOL_VERSION))
|
||||
|
||||
def test_date_io(self):
|
||||
today = date.today()
|
||||
self.DateTest.objects.create(test_id=0, created_at=today)
|
||||
|
@@ -311,30 +311,32 @@ class NonModelFailureTest(BaseCassEngTestCase):
|
||||
with self.assertRaises(CQLEngineException):
|
||||
sync_table(self.FakeModel)
|
||||
|
||||
class StaticColumnTests(BaseCassEngTestCase):
|
||||
def test_static_columns(self):
|
||||
if PROTOCOL_VERSION < 2:
|
||||
raise unittest.SkipTest("Native protocol 2+ required, currently using: {0}".format(PROTOCOL_VERSION))
|
||||
|
||||
@unittest.skipUnless(PROTOCOL_VERSION >= 2, "only runs against the cql3 protocol v2.0")
|
||||
def test_static_columns():
|
||||
class StaticModel(Model):
|
||||
id = columns.Integer(primary_key=True)
|
||||
c = columns.Integer(primary_key=True)
|
||||
name = columns.Text(static=True)
|
||||
class StaticModel(Model):
|
||||
id = columns.Integer(primary_key=True)
|
||||
c = columns.Integer(primary_key=True)
|
||||
name = columns.Text(static=True)
|
||||
|
||||
drop_table(StaticModel)
|
||||
drop_table(StaticModel)
|
||||
|
||||
session = get_session()
|
||||
session = get_session()
|
||||
|
||||
with mock.patch.object(session, "execute", wraps=session.execute) as m:
|
||||
with mock.patch.object(session, "execute", wraps=session.execute) as m:
|
||||
sync_table(StaticModel)
|
||||
|
||||
assert m.call_count > 0
|
||||
statement = m.call_args[0][0].query_string
|
||||
assert '"name" text static' in statement, statement
|
||||
|
||||
# if we sync again, we should not apply an alter w/ a static
|
||||
sync_table(StaticModel)
|
||||
|
||||
assert m.call_count > 0
|
||||
statement = m.call_args[0][0].query_string
|
||||
assert '"name" text static' in statement, statement
|
||||
with mock.patch.object(session, "execute", wraps=session.execute) as m2:
|
||||
sync_table(StaticModel)
|
||||
|
||||
# if we sync again, we should not apply an alter w/ a static
|
||||
sync_table(StaticModel)
|
||||
|
||||
with mock.patch.object(session, "execute", wraps=session.execute) as m2:
|
||||
sync_table(StaticModel)
|
||||
|
||||
assert len(m2.call_args_list) == 1
|
||||
assert "ALTER" not in m2.call_args[0][0].query_string
|
||||
assert len(m2.call_args_list) == 1
|
||||
assert "ALTER" not in m2.call_args[0][0].query_string
|
||||
|
@@ -437,7 +437,7 @@ class TestQuerying(BaseCassEngTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if PROTOCOL_VERSION < 4:
|
||||
raise unittest.SkipTest("Date query tests require native protocol 4+, currently using: {0}".format(PROTOCOL_VERSION))
|
||||
return
|
||||
|
||||
super(TestQuerying, cls).setUpClass()
|
||||
drop_table(TestQueryModel)
|
||||
@@ -445,9 +445,16 @@ class TestQuerying(BaseCassEngTestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if PROTOCOL_VERSION < 4:
|
||||
return
|
||||
|
||||
super(TestQuerying, cls).tearDownClass()
|
||||
drop_table(TestQueryModel)
|
||||
|
||||
def setUp(self):
|
||||
if PROTOCOL_VERSION < 4:
|
||||
raise unittest.SkipTest("Date query tests require native protocol 4+, currently using: {0}".format(PROTOCOL_VERSION))
|
||||
|
||||
def test_query_with_date(self):
|
||||
uid = uuid4()
|
||||
day = date(2013, 11, 26)
|
||||
|
@@ -32,8 +32,7 @@ from tests.integration.cqlengine.base import BaseCassEngTestCase
|
||||
|
||||
class UserDefinedTypeTests(BaseCassEngTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
def setUp(self):
|
||||
if PROTOCOL_VERSION < 3:
|
||||
raise unittest.SkipTest("UDTs require native protocol 3+, currently using: {0}".format(PROTOCOL_VERSION))
|
||||
|
||||
|
@@ -689,23 +689,25 @@ class TestObjectsProperty(BaseQuerySetUsage):
|
||||
len(TestModel.objects) # evaluate queryset
|
||||
assert TestModel.objects._result_cache is None
|
||||
|
||||
class PageQueryTests(BaseCassEngTestCase):
|
||||
def test_paged_result_handling(self):
|
||||
if PROTOCOL_VERSION < 2:
|
||||
raise unittest.SkipTest("Paging requires native protocol 2+, currently using: {0}".format(PROTOCOL_VERSION))
|
||||
|
||||
@unittest.skipUnless(PROTOCOL_VERSION >= 2, "only runs against the cql3 protocol v2.0")
|
||||
def test_paged_result_handling():
|
||||
# addresses #225
|
||||
class PagingTest(Model):
|
||||
id = columns.Integer(primary_key=True)
|
||||
val = columns.Integer()
|
||||
sync_table(PagingTest)
|
||||
# addresses #225
|
||||
class PagingTest(Model):
|
||||
id = columns.Integer(primary_key=True)
|
||||
val = columns.Integer()
|
||||
sync_table(PagingTest)
|
||||
|
||||
PagingTest.create(id=1, val=1)
|
||||
PagingTest.create(id=2, val=2)
|
||||
PagingTest.create(id=1, val=1)
|
||||
PagingTest.create(id=2, val=2)
|
||||
|
||||
session = get_session()
|
||||
with mock.patch.object(session, 'default_fetch_size', 1):
|
||||
results = PagingTest.objects()[:]
|
||||
session = get_session()
|
||||
with mock.patch.object(session, 'default_fetch_size', 1):
|
||||
results = PagingTest.objects()[:]
|
||||
|
||||
assert len(results) == 2
|
||||
assert len(results) == 2
|
||||
|
||||
|
||||
class ModelQuerySetTimeoutTestCase(BaseQuerySetUsage):
|
||||
|
Reference in New Issue
Block a user