Implemented patroni --version (#1291)

That required a refactoring of `Config` and `Patroni` classes. Now one has to explicitely create the instance of `Config` before creating `Patroni`.

The Config file can optionally call the validate function.
This commit is contained in:
Igor Yanchenko
2019-12-02 12:14:19 +01:00
committed by Alexander Kukushkin
parent cc0df4900b
commit 726ee46111
9 changed files with 50 additions and 36 deletions
+6 -2
View File
@@ -5,6 +5,7 @@ import signal
import time
import unittest
import patroni.config as config
from mock import Mock, PropertyMock, patch
from patroni.api import RestApiServer
from patroni.async_executor import AsyncExecutor
@@ -40,7 +41,9 @@ class MockFrozenImporter(object):
@patch.object(etcd.Client, 'read', etcd_read)
class TestPatroni(unittest.TestCase):
@patch('sys.argv', ['patroni.py', 'postgres0.yml'])
def test_no_config(self):
self.assertRaises(SystemExit, patroni_main)
@patch('pkgutil.get_importer', Mock(return_value=MockFrozenImporter()))
@patch('sys.frozen', Mock(return_value=True), create=True)
@patch.object(BaseHTTPServer.HTTPServer, '__init__', Mock())
@@ -53,7 +56,8 @@ class TestPatroni(unittest.TestCase):
RestApiServer._BaseServer__shutdown_request = True
RestApiServer.socket = 0
os.environ['PATRONI_POSTGRESQL_DATA_DIR'] = 'data/test0'
self.p = Patroni()
conf = config.Config('postgres0.yml')
self.p = Patroni(conf)
def tearDown(self):
logging.getLogger().handlers[:] = self._handlers