From d56b8772e5e7b948dc4293b5ee5fb055db069fad Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 20 May 2015 18:21:08 +0200 Subject: [PATCH] Update unit tests --- tests/test_governor.py | 1 + tests/test_postgresql.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/test_governor.py b/tests/test_governor.py index ed7ae32e..05fc5a1e 100644 --- a/tests/test_governor.py +++ b/tests/test_governor.py @@ -52,6 +52,7 @@ class TestGovernor(unittest.TestCase): with open('postgres0.yml', 'r') as f: config = yaml.load(f) g = Governor(config) + g.postgresql.should_use_s3_to_create_replica = false g.etcd.base_client_url = 'http://remote' g.etcd.client_url g.postgresql.data_directory_empty = true diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index 297bd929..7fa5dcf7 100644 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -7,10 +7,18 @@ from helpers.etcd import Cluster, Member from helpers.postgresql import Postgresql +def nop(*args, **kwargs): + pass + + def os_system(cmd): return 0 +def false(*args, **kwargs): + return False + + class MockCursor: def __init__(self): @@ -75,8 +83,12 @@ class TestPostgresql(unittest.TestCase): def set_up(self): os.system = os_system - self.p = Postgresql({'name': 'test0', 'data_dir': 'data/test0', 'listen': '127.0.0.1, 127.0.0.2:5432', 'connect_address': '127.0.0.2:5432', 'replication': { - 'username': 'replicator', 'password': 'rep-pass', 'network': '127.0.0.1/32'}, 'parameters': {'foo': 'bar'}, 'recovery_conf': {'foo': 'bar'}}) + shutil.copy = nop + self.p = Postgresql({'name': 'test0', 'data_dir': 'data/test0', 'listen': '127.0.0.1, 127.0.0.2:5432', + 'connect_address': '127.0.0.2:5432', 'superuser': {'password': ''}, + 'admin': {'username': 'admin', 'password': 'admin'}, 'replication': { + 'username': 'replicator', 'password': 'rep-pass', 'network': '127.0.0.1/32'}, + 'parameters': {'foo': 'bar'}, 'recovery_conf': {'foo': 'bar'}}) psycopg2.connect = psycopg2_connect if not os.path.exists(self.p.data_dir): os.makedirs(self.p.data_dir)