mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
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:
committed by
Alexander Kukushkin
parent
cc0df4900b
commit
726ee46111
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user