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