diff --git a/salt/modules/monit.py b/salt/modules/monit.py index 6097a36169..8a731287ae 100644 --- a/salt/modules/monit.py +++ b/salt/modules/monit.py @@ -5,13 +5,16 @@ service watcher. ''' from __future__ import absolute_import +# Import python libs +import re + # Import salt libs import salt.utils -import re - +# Function alias to make sure not to shadow built-in's __func_alias__ = { 'id_': 'id', + 'reload_': 'reload', } @@ -157,7 +160,7 @@ def status(svc_name=''): return ret -def reload(): +def reload_(): ''' .. versionadded:: Boron @@ -246,6 +249,7 @@ def id_(reset=False): ret = out.split(':')[-1].strip() return ret + def validate(): ''' .. versionadded:: Boron diff --git a/tests/unit/modules/monit_test.py b/tests/unit/modules/monit_test.py index c9c49376fd..7c5c5099fc 100644 --- a/tests/unit/modules/monit_test.py +++ b/tests/unit/modules/monit_test.py @@ -21,7 +21,6 @@ ensure_in_syspath('../../') # Import Salt Libs from salt.modules import monit - # Globals monit.__salt__ = {} @@ -99,13 +98,13 @@ class MonitTestCase(TestCase): ''' mock = MagicMock(return_value=0) with patch.dict(monit.__salt__, {'cmd.retcode': mock}): - self.assertTrue(monit.reload()) + self.assertTrue(monit.reload_()) def test_version(self): ''' Test for Display version from monit -V ''' - mock = MagicMock(return_value="This is Monit version 5.14\nA\B") + mock = MagicMock(return_value="This is Monit version 5.14\nA\nB") with patch.dict(monit.__salt__, {'cmd.run': mock}): self.assertEqual(monit.version(), '5.14') @@ -116,7 +115,7 @@ class MonitTestCase(TestCase): mock = MagicMock( return_value='Monit ID: d3b1aba48527dd599db0e86f5ad97120') with patch.dict(monit.__salt__, {'cmd.run': mock}): - self.assertEqual(monit.id(), 'd3b1aba48527dd599db0e86f5ad97120') + self.assertEqual(monit.id_(), 'd3b1aba48527dd599db0e86f5ad97120') def test_reset_id(self): ''' @@ -127,7 +126,7 @@ class MonitTestCase(TestCase): } mock = MagicMock(return_value=expected) with patch.dict(monit.__salt__, {'cmd.run_all': mock}): - self.assertEqual(monit.id(reset=True), + self.assertEqual(monit.id_(reset=True), 'd3b1aba48527dd599db0e86f5ad97120') def test_configtest(self):