A small fix in unit tests (#2427)

Not all external resources were properly mocked
This commit is contained in:
Alexander Kukushkin
2022-10-13 10:53:13 +02:00
committed by GitHub
parent 8a227aa743
commit 816b66311b
3 changed files with 4 additions and 0 deletions
+2
View File
@@ -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']},
+1
View File
@@ -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)):
+1
View File
@@ -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)