* bugfix: pass an arguments to a callback

This commit is contained in:
Alexander Kukushkin
2016-12-16 15:44:04 +01:00
committed by GitHub
parent 8c0712047e
commit a5e79bce9d
2 changed files with 9 additions and 3 deletions
+6 -1
View File
@@ -610,7 +610,12 @@ class Postgresql(object):
self.__cb_called = True
if self.callback and cb_name in self.callback:
self._callback_executor.call(self.callback[cb_name])
cmd = self.callback[cb_name]
try:
cmd = shlex.split(self.callback[cb_name]) + [cb_name, self.role, self.scope]
self._callback_executor.call(cmd)
except Exception:
logger.exception('callback %s %s %s %s failed', cmd, cb_name, self.role, self.scope)
@property
def role(self):
+3 -2
View File
@@ -279,6 +279,7 @@ class TestPostgresql(unittest.TestCase):
@patch.object(builtins, 'open', MagicMock())
def test_write_pgpass(self):
self.p.write_pgpass({'host': 'localhost', 'port': '5432', 'user': 'foo'})
self.p.write_pgpass({'host': 'localhost', 'port': '5432', 'user': 'foo', 'password': 'bar'})
def test_checkpoint(self):
@@ -423,9 +424,9 @@ class TestPostgresql(unittest.TestCase):
def test_is_running(self):
self.assertFalse(self.p.is_running())
@patch('subprocess.Popen', Mock(side_effect=OSError))
@patch('shlex.split', Mock(side_effect=OSError))
def test_call_nowait(self):
self.assertFalse(self.p.call_nowait('on_start'))
self.assertIsNone(self.p.call_nowait('on_start'))
def test_non_existing_callback(self):
self.assertFalse(self.p.call_nowait('foobar'))