From 3ec54e510c981975e3bdae55d216d97f4b559df8 Mon Sep 17 00:00:00 2001 From: Itai Shirav Date: Fri, 29 May 2020 12:53:14 +0300 Subject: [PATCH] Fix tests that fail on older ClickHouse versions --- tests/test_alias_fields.py | 4 ++-- tests/test_engines.py | 3 +++ tests/test_funcs.py | 5 +++-- tests/test_uuid_fields.py | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_alias_fields.py b/tests/test_alias_fields.py index 48d408f..6f8f1f2 100644 --- a/tests/test_alias_fields.py +++ b/tests/test_alias_fields.py @@ -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',)) diff --git a/tests/test_engines.py b/tests/test_engines.py index 0258186..06c9f02 100644 --- a/tests/test_engines.py +++ b/tests/test_engines.py @@ -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'), diff --git a/tests/test_funcs.py b/tests/test_funcs.py index b296cbc..fa352d8 100644 --- a/tests/test_funcs.py +++ b/tests/test_funcs.py @@ -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()) diff --git a/tests/test_uuid_fields.py b/tests/test_uuid_fields.py index 37bee2c..d81e8eb 100644 --- a/tests/test_uuid_fields.py +++ b/tests/test_uuid_fields.py @@ -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()