mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Less lines in the test
This commit is contained in:
+18
-35
@@ -159,53 +159,36 @@ class TestConfig(unittest.TestCase):
|
|||||||
def test__validate_failover_tags(self, mock_logger):
|
def test__validate_failover_tags(self, mock_logger):
|
||||||
"""Ensures that only one of `nofailover` or `failover_priority` can be provided"""
|
"""Ensures that only one of `nofailover` or `failover_priority` can be provided"""
|
||||||
# Providing one of `nofailover` or `failover_priority` is fine
|
# Providing one of `nofailover` or `failover_priority` is fine
|
||||||
config = {"nofailover": True}
|
for tags_config in [{"nofailover": True}, {"failover_priority": 1}]:
|
||||||
self.assertIsNone(Config._validate_failover_tags(config))
|
self.assertIsNone(Config._validate_failover_tags(tags_config))
|
||||||
mock_logger.warning.assert_not_called()
|
|
||||||
|
|
||||||
config = {"failover_priority": 1}
|
|
||||||
self.assertIsNone(Config._validate_failover_tags(config))
|
|
||||||
mock_logger.warning.assert_not_called()
|
mock_logger.warning.assert_not_called()
|
||||||
|
|
||||||
# Providing both `nofailover` and `failover_priority` is fine if consistent
|
# Providing both `nofailover` and `failover_priority` is fine if consistent
|
||||||
config = {"nofailover": False, "failover_priority": 1}
|
for tags_config in [
|
||||||
self.assertIsNone(Config._validate_failover_tags(config))
|
{"nofailover": False, "failover_priority": 1},
|
||||||
self.assertIn('nofailover', config)
|
{"nofailover": True, "failover_priority": 0}]:
|
||||||
self.assertIn('failover_priority', config)
|
self.assertIsNone(Config._validate_failover_tags(tags_config))
|
||||||
mock_logger.warning.assert_not_called()
|
self.assertIn('nofailover', tags_config)
|
||||||
|
self.assertIn('failover_priority', tags_config)
|
||||||
config = {"nofailover": True, "failover_priority": 0}
|
|
||||||
self.assertIsNone(Config._validate_failover_tags(config))
|
|
||||||
self.assertIn('nofailover', config)
|
|
||||||
self.assertIn('failover_priority', config)
|
|
||||||
mock_logger.warning.assert_not_called()
|
mock_logger.warning.assert_not_called()
|
||||||
|
|
||||||
# Providing both inconsistently should log a warning
|
# Providing both inconsistently should log a warning
|
||||||
config = {"nofailover": False, "failover_priority": 0}
|
for tags_config in [
|
||||||
self.assertIsNone(Config._validate_failover_tags(config))
|
{"nofailover": False, "failover_priority": 0},
|
||||||
self.assertIn('nofailover', config)
|
{"nofailover": True, "failover_priority": 1}]:
|
||||||
self.assertNotIn('failover_priority', config)
|
initial_config = tags_config.copy()
|
||||||
|
self.assertIsNone(Config._validate_failover_tags(tags_config))
|
||||||
|
self.assertIn('nofailover', tags_config)
|
||||||
|
self.assertNotIn('failover_priority', tags_config)
|
||||||
mock_logger.warning.assert_called_once_with(
|
mock_logger.warning.assert_called_once_with(
|
||||||
'Conflicting configuration between nofailover: %s and failover_priority: %s.'
|
'Conflicting configuration between nofailover: %s and failover_priority: %s.'
|
||||||
+ ' Defaulting to nofailover: %s',
|
+ ' Defaulting to nofailover: %s',
|
||||||
False,
|
initial_config['nofailover'],
|
||||||
0,
|
initial_config['failover_priority'],
|
||||||
False
|
initial_config['nofailover']
|
||||||
)
|
)
|
||||||
mock_logger.warning.reset_mock()
|
mock_logger.warning.reset_mock()
|
||||||
|
|
||||||
config = {"nofailover": True, "failover_priority": 1}
|
|
||||||
self.assertIsNone(Config._validate_failover_tags(config))
|
|
||||||
self.assertIn('nofailover', config)
|
|
||||||
self.assertNotIn('failover_priority', config)
|
|
||||||
mock_logger.warning.assert_called_once_with(
|
|
||||||
'Conflicting configuration between nofailover: %s and failover_priority: %s.'
|
|
||||||
+ ' Defaulting to nofailover: %s',
|
|
||||||
True,
|
|
||||||
1,
|
|
||||||
True
|
|
||||||
)
|
|
||||||
|
|
||||||
def test__process_postgresql_parameters(self):
|
def test__process_postgresql_parameters(self):
|
||||||
expected_params = {
|
expected_params = {
|
||||||
'f.oo': 'bar', # not in ConfigHandler.CMDLINE_OPTIONS
|
'f.oo': 'bar', # not in ConfigHandler.CMDLINE_OPTIONS
|
||||||
|
|||||||
Reference in New Issue
Block a user