From 06ed53e4ecfc635273f45b577bbbfaedd08ab00e Mon Sep 17 00:00:00 2001 From: Itai Shirav Date: Sun, 20 Aug 2017 09:46:00 +0300 Subject: [PATCH] fix test_freeze --- tests/test_system_models.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/test_system_models.py b/tests/test_system_models.py index 0412ad6..d932bd6 100644 --- a/tests/test_system_models.py +++ b/tests/test_system_models.py @@ -1,6 +1,5 @@ import unittest from datetime import date -from time import sleep import os import shutil from infi.clickhouse_orm.database import Database @@ -11,7 +10,8 @@ from infi.clickhouse_orm.system_models import SystemPart class SystemPartTest(unittest.TestCase): - BACKUP_DIR = '/opt/clickhouse/shadow/' + + BACKUP_DIRS = ['/var/lib/clickhouse/shadow', '/opt/clickhouse/shadow/'] def setUp(self): self.database = Database('test-db') @@ -22,10 +22,11 @@ class SystemPartTest(unittest.TestCase): self.database.drop_database() def _get_backups(self): - if not os.path.exists(self.BACKUP_DIR): - return [] - _, dirnames, _ = next(os.walk(self.BACKUP_DIR)) - return dirnames + for dir in self.BACKUP_DIRS: + if os.path.exists(dir): + _, dirnames, _ = next(os.walk(dir)) + return dirnames + raise unittest.SkipTest('Cannot find backups dir') def test_get_all(self): parts = SystemPart.get(self.database) @@ -61,11 +62,8 @@ class SystemPartTest(unittest.TestCase): # There can be other backups in the folder prev_backups = set(self._get_backups()) parts[0].freeze() - sleep(1) backups = set(self._get_backups()) self.assertEqual(len(backups), len(prev_backups) + 1) - # Clean created backup - shutil.rmtree(self.BACKUP_DIR + '{0}'.format(list(backups - prev_backups)[0])) def test_fetch(self): # TODO Not tested, as I have no replication set