modules/monit: alias reload function also and fix lint issues

This commit is contained in:
Sofian Brabez 2015-12-01 21:32:20 +01:00
parent 0d2df70008
commit a2e5586cd4
2 changed files with 11 additions and 8 deletions

View File

@ -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

View File

@ -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):