Fix tests that fail on older ClickHouse versions

This commit is contained in:
Itai Shirav 2020-05-29 12:53:14 +03:00
parent b2af10b11c
commit 3ec54e510c
4 changed files with 10 additions and 4 deletions

View File

@ -37,7 +37,7 @@ class AliasFieldsTest(unittest.TestCase):
self.assertEqual(results[0].alias_int, instance.int_field)
self.assertEqual(results[0].alias_str, instance.str_field)
self.assertEqual(results[0].alias_date, instance.date_field)
self.assertEqual(results[0].alias_func, '08/30/16')
self.assertEqual(results[0].alias_func, 201608)
def test_assignment_error(self):
# I can't prevent assigning at all, in case db.select statements with model provided sets model fields.
@ -74,6 +74,6 @@ class ModelWithAliasFields(Model):
alias_str = StringField(alias=u'str_field')
alias_int = Int32Field(alias='int_field')
alias_date = DateField(alias='date_field')
alias_func = StringField(alias=F.formatDateTime(date_field, '%D'))
alias_func = Int32Field(alias=F.toYYYYMM(date_field))
engine = MergeTree('date_field', ('date_field',))

View File

@ -168,6 +168,9 @@ class EnginesTestCase(_EnginesHelperTestCase):
self.assertEqual('(201701, 13)'.replace(' ', ''), parts[1].partition.replace(' ', ''))
def test_custom_primary_key(self):
if self.database.server_version < (18, 1):
raise unittest.SkipTest('ClickHouse version too old')
class TestModel(SampleModel):
engine = MergeTree(
order_by=('date', 'event_id', 'event_group'),

View File

@ -560,9 +560,7 @@ class FuncsTestCase(TestCaseWithData):
x = 17
s = 'hello'
url = 'http://example.com/a/b/c/d'
self._test_func(F.hex(F.halfMD5(*args)))
self._test_func(F.hex(F.MD5(s)))
self._test_func(F.hex(F.sipHash64(*args)))
self._test_func(F.hex(F.sipHash128(s)))
self._test_func(F.hex(F.cityHash64(*args)))
self._test_func(F.hex(F.intHash32(x)))
@ -584,6 +582,9 @@ class FuncsTestCase(TestCaseWithData):
self._test_func(F.hex(F.murmurHash3_128(s)))
self._test_func(F.hex(F.xxHash32(*args)))
self._test_func(F.hex(F.xxHash64(*args)))
if self.database.server_version >= (18, 1):
self._test_func(F.hex(F.halfMD5(*args)))
self._test_func(F.hex(F.sipHash64(*args)))
def test_rand_functions(self):
self._test_func(F.rand())

View File

@ -16,6 +16,8 @@ class UUIDFieldsTest(unittest.TestCase):
self.database.drop_database()
def test_uuid_field(self):
if self.database.server_version < (18, 1):
raise unittest.SkipTest('ClickHouse version too old')
# Create a model
class TestModel(Model):
i = Int16Field()