From bc900c2ef1e372254b66733e770bd46db50386a8 Mon Sep 17 00:00:00 2001 From: Itai Shirav Date: Sat, 27 Jun 2020 00:26:21 +0300 Subject: [PATCH] Skip mutations test on old ClickHouse versions --- tests/test_mutations.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_mutations.py b/tests/test_mutations.py index d677ae1..874c7bd 100644 --- a/tests/test_mutations.py +++ b/tests/test_mutations.py @@ -1,3 +1,4 @@ +import unittest from infi.clickhouse_orm import F from .base_test_with_data import * from time import sleep @@ -5,19 +6,23 @@ from time import sleep class MutationsTestCase(TestCaseWithData): + def setUp(self): + super().setUp() + if self.database.server_version < (18,): + raise unittest.SkipTest('ClickHouse version too old') + self._insert_all() + def _wait_for_mutations(self): sql = 'SELECT * FROM system.mutations WHERE is_done = 0' while list(self.database.raw(sql)): sleep(0.25) def test_delete_all(self): - self._insert_all() Person.objects_in(self.database).delete() self._wait_for_mutations() self.assertFalse(Person.objects_in(self.database)) def test_delete_with_where_cond(self): - self._insert_all() cond = Person.first_name == 'Cassady' self.assertTrue(Person.objects_in(self.database).filter(cond)) Person.objects_in(self.database).filter(cond).delete() @@ -26,7 +31,6 @@ class MutationsTestCase(TestCaseWithData): self.assertTrue(Person.objects_in(self.database).exclude(cond)) def test_delete_with_prewhere_cond(self): - self._insert_all() cond = F.toYear(Person.birthday) == 1977 self.assertTrue(Person.objects_in(self.database).filter(cond)) Person.objects_in(self.database).filter(cond, prewhere=True).delete() @@ -35,35 +39,30 @@ class MutationsTestCase(TestCaseWithData): self.assertTrue(Person.objects_in(self.database).exclude(cond)) def test_update_all(self): - self._insert_all() Person.objects_in(self.database).update(height=0) self._wait_for_mutations() for p in Person.objects_in(self.database): print(p.height) self.assertFalse(Person.objects_in(self.database).exclude(height=0)) def test_update_with_where_cond(self): - self._insert_all() cond = Person.first_name == 'Cassady' Person.objects_in(self.database).filter(cond).update(height=0) self._wait_for_mutations() self.assertFalse(Person.objects_in(self.database).filter(cond).exclude(height=0)) def test_update_with_prewhere_cond(self): - self._insert_all() cond = F.toYear(Person.birthday) == 1977 Person.objects_in(self.database).filter(cond, prewhere=True).update(height=0) self._wait_for_mutations() self.assertFalse(Person.objects_in(self.database).filter(cond).exclude(height=0)) def test_update_multiple_fields(self): - self._insert_all() Person.objects_in(self.database).update(height=0, passport=None) self._wait_for_mutations() self.assertFalse(Person.objects_in(self.database).exclude(height=0)) self.assertFalse(Person.objects_in(self.database).exclude(passport=None)) def test_chained_update(self): - self._insert_all() Person.objects_in(self.database).update(height=F.rand()).update(passport=99999) self._wait_for_mutations() self.assertFalse(Person.objects_in(self.database).exclude(passport=99999))