diff --git a/tests/test_consul.py b/tests/test_consul.py index 321d4ef8..291eda69 100644 --- a/tests/test_consul.py +++ b/tests/test_consul.py @@ -161,6 +161,7 @@ class TestConsul(unittest.TestCase): self.c.write_leader_optime('1') @patch.object(consul.Consul.Session, 'renew', Mock()) + @patch.object(consul.Consul.KV, 'put', Mock(side_effect=ConsulException)) def test_update_leader(self): self.c.update_leader(12345) @@ -217,6 +218,7 @@ class TestConsul(unittest.TestCase): d['role'] = 'bla' self.assertIsNone(self.c.update_service({}, d)) + @patch.object(consul.Consul.KV, 'put', Mock(side_effect=ConsulException)) def test_reload_config(self): self.assertEqual([], self.c._service_tags) self.c.reload_config({'consul': {'token': 'foo', 'register_service': True, 'service_tags': ['foo']}, diff --git a/tests/test_ha.py b/tests/test_ha.py index b5c496c1..d7d28bc1 100644 --- a/tests/test_ha.py +++ b/tests/test_ha.py @@ -409,6 +409,7 @@ class TestHa(PostgresInit): self.ha.has_lock = true self.assertEqual(self.ha.run_cycle(), 'no action. I am (postgresql0), the leader with the lock') + @patch.object(Postgresql, '_wait_for_connection_close', Mock()) def test_demote_because_not_having_lock(self): self.ha.cluster.is_unlocked = false with patch.object(Watchdog, 'is_running', PropertyMock(return_value=True)): diff --git a/tests/test_patroni.py b/tests/test_patroni.py index 74821704..44e4c0c9 100644 --- a/tests/test_patroni.py +++ b/tests/test_patroni.py @@ -54,6 +54,7 @@ class TestPatroni(unittest.TestCase): self.assertRaises(SystemExit, patroni_main) @patch('sys.argv', ['patroni.py', '--validate-config', 'postgres0.yml']) + @patch('socket.socket.connect_ex', Mock(return_value=1)) def test_validate_config(self): self.assertRaises(SystemExit, patroni_main)