Fix flake8 for tests directory (#3168)

Followup on #3123
This commit is contained in:
Alexander Kukushkin
2024-09-16 17:20:00 +02:00
committed by GitHub
parent 416a0f7c8b
commit bfa9b0ca4b
5 changed files with 8 additions and 6 deletions
+1
View File
@@ -88,6 +88,7 @@ class _Lint(_Command):
def aux_directories(self):
for dir_name in ('tests', 'features'):
yield dir_name
for root, dirs, files in os.walk(dir_name):
for name in dirs:
yield os.path.join(root, name)
+4 -2
View File
@@ -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())
-2
View File
@@ -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)
+2 -1
View File
@@ -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])), \