mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
+4
-2
@@ -584,14 +584,16 @@ class TestHa(PostgresInit):
|
||||
self.ha.patroni.request.return_value.status = 200
|
||||
with patch('patroni.ha.logger.info') as mock_logger:
|
||||
ret = self.ha.call_failsafe_member({}, member)
|
||||
self.assertEqual(mock_logger.call_args_list[0][0], ('Got response from %s %s: %s', 'test', 'http://localhost:8011/failsafe', 'Accepted'))
|
||||
self.assertEqual(mock_logger.call_args_list[0][0],
|
||||
('Got response from %s %s: %s', 'test', 'http://localhost:8011/failsafe', 'Accepted'))
|
||||
self.assertTrue(ret.accepted)
|
||||
|
||||
e = Exception('request failed')
|
||||
self.ha.patroni.request.side_effect = e
|
||||
with patch('patroni.ha.logger.warning') as mock_logger:
|
||||
ret = self.ha.call_failsafe_member({}, member)
|
||||
self.assertEqual(mock_logger.call_args_list[0][0], ('Request failed to %s: POST %s (%s)', 'test', 'http://localhost:8011/failsafe', e))
|
||||
self.assertEqual(mock_logger.call_args_list[0][0],
|
||||
('Request failed to %s: POST %s (%s)', 'test', 'http://localhost:8011/failsafe', e))
|
||||
self.assertFalse(ret.accepted)
|
||||
|
||||
@patch('time.sleep', Mock())
|
||||
|
||||
@@ -106,7 +106,6 @@ class TestPatroni(unittest.TestCase):
|
||||
self.p.apply_dynamic_configuration(cluster)
|
||||
self.assertEqual(self.p.config._dynamic_configuration['ttl'], 40)
|
||||
|
||||
|
||||
@patch('sys.argv', ['patroni.py', 'postgres0.yml'])
|
||||
@patch('time.sleep', Mock(side_effect=SleepException))
|
||||
@patch.object(etcd.Client, 'delete', Mock())
|
||||
@@ -320,4 +319,3 @@ class TestPatroni(unittest.TestCase):
|
||||
result = self.p.ensure_dcs_access()
|
||||
self.assertEqual(result, None)
|
||||
self.assertEqual(mock_logger.call_count, 2)
|
||||
|
||||
|
||||
@@ -1113,7 +1113,7 @@ class TestPostgresql(BaseTestPostgresql):
|
||||
file1_mock = MagicMock(**file1_attrs)
|
||||
file1_mock.name = '__init__.py'
|
||||
file2_attrs = {'is_file.return_value': False, 'is_dir.return_value': True,
|
||||
'iterdir.side_effect': PermissionError(13, 'Permission denied')}
|
||||
'iterdir.side_effect': PermissionError(13, 'Permission denied')}
|
||||
file2_mock = MagicMock(**file2_attrs)
|
||||
file2_mock.name = '__pycache__'
|
||||
file3_attrs = {'is_file.return_value': True, 'is_dir.return_value': False}
|
||||
|
||||
+2
-1
@@ -321,7 +321,8 @@ class TestSlotsHandler(BaseTestPostgresql):
|
||||
patch.object(SlotsHandler, 'drop_replication_slot', Mock(return_value=(True, False))), \
|
||||
patch('patroni.postgresql.slots.logger.warning') as mock_warning:
|
||||
self.s.sync_replication_slots(cluster, self.tags)
|
||||
self.assertEqual(mock_warning.call_args_list[-1][0], ("Unable to drop replication slot '%s', slot is active", 'test_1'))
|
||||
self.assertEqual(mock_warning.call_args_list[-1][0],
|
||||
("Unable to drop replication slot '%s', slot is active", 'test_1'))
|
||||
|
||||
with patch.object(SlotsHandler, '_query', Mock(side_effect=[[('test_1', 'physical', 1, 12345, None, None,
|
||||
None, None, None)], Exception])), \
|
||||
|
||||
Reference in New Issue
Block a user