mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
A small fix in unit tests (#2427)
Not all external resources were properly mocked
This commit is contained in:
@@ -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']},
|
||||
|
||||
@@ -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)):
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user