mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fine tuning and fix tests
This commit is contained in:
parent
d50916ccdd
commit
9e40c3a6a6
3 changed files with 18 additions and 16 deletions
|
@ -52,7 +52,7 @@ def enabled(name, runas=None):
|
|||
return ret
|
||||
|
||||
if plugin_enabled:
|
||||
ret['comment'] = 'Plugin {0} is already enabled.'.format(name)
|
||||
ret['comment'] = 'Plugin \'{0}\' is already enabled.'.format(name)
|
||||
return ret
|
||||
|
||||
if not __opts__['test']:
|
||||
|
@ -66,10 +66,10 @@ def enabled(name, runas=None):
|
|||
|
||||
if __opts__['test'] and ret['changes']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'Plugin {0} is set to be enabled.'.format(name)
|
||||
ret['comment'] = 'Plugin \'{0}\' is set to be enabled.'.format(name)
|
||||
return ret
|
||||
|
||||
ret['comment'] = 'Plugin {0} was enabled.'.format(name)
|
||||
ret['comment'] = 'Plugin \'{0}\' was enabled.'.format(name)
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -93,7 +93,7 @@ def disabled(name, runas=None):
|
|||
return ret
|
||||
|
||||
if not plugin_enabled:
|
||||
ret['comment'] = 'Plugin {0} is already. disabled'.format(name)
|
||||
ret['comment'] = 'Plugin \'{0}\' is already disabled.'.format(name)
|
||||
return ret
|
||||
|
||||
if not __opts__['test']:
|
||||
|
@ -107,8 +107,8 @@ def disabled(name, runas=None):
|
|||
|
||||
if __opts__['test'] and ret['changes']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'Plugin {0} is set to be disabled.'.format(name)
|
||||
ret['comment'] = 'Plugin \'{0}\' is set to be disabled.'.format(name)
|
||||
return ret
|
||||
|
||||
ret['comment'] = 'Plugin {0} was disabled.'.format(name)
|
||||
ret['comment'] = 'Plugin \'{0}\' was disabled.'.format(name)
|
||||
return ret
|
||||
|
|
|
@ -352,9 +352,9 @@ class RabbitmqTestCase(TestCase):
|
|||
'''
|
||||
Test if it return whether the plugin is enabled.
|
||||
'''
|
||||
mock_run = MagicMock(return_value='saltstack')
|
||||
mock_run = MagicMock(return_value={'retcode': 0, 'stdout': 'saltstack'})
|
||||
mock_pkg = MagicMock(return_value='')
|
||||
with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run,
|
||||
with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run,
|
||||
'pkg.version': mock_pkg}):
|
||||
self.assertTrue(rabbitmq.plugin_is_enabled('salt'))
|
||||
|
||||
|
|
|
@ -46,13 +46,14 @@ class RabbitmqPluginTestCase(TestCase):
|
|||
mock = MagicMock(side_effect=[True, False])
|
||||
with patch.dict(rabbitmq_plugin.__salt__,
|
||||
{'rabbitmq.plugin_is_enabled': mock}):
|
||||
comt = ('Plugin some_plugin is already enabled')
|
||||
ret.update({'comment': comt})
|
||||
comment = 'Plugin \'some_plugin\' is already enabled.'
|
||||
ret.update({'comment': comment})
|
||||
self.assertDictEqual(rabbitmq_plugin.enabled(name), ret)
|
||||
|
||||
with patch.dict(rabbitmq_plugin.__opts__, {'test': True}):
|
||||
comt = ('Plugin some_plugin is set to be enabled')
|
||||
ret.update({'comment': comt, 'result': None})
|
||||
comment = 'Plugin \'some_plugin\' is set to be enabled.'
|
||||
changes = {'new': 'some_plugin', 'old': ''}
|
||||
ret.update({'comment': comment, 'result': None, 'changes': changes})
|
||||
self.assertDictEqual(rabbitmq_plugin.enabled(name), ret)
|
||||
|
||||
# 'disabled' function tests: 1
|
||||
|
@ -71,13 +72,14 @@ class RabbitmqPluginTestCase(TestCase):
|
|||
mock = MagicMock(side_effect=[False, True])
|
||||
with patch.dict(rabbitmq_plugin.__salt__,
|
||||
{'rabbitmq.plugin_is_enabled': mock}):
|
||||
comt = ('Plugin some_plugin is not enabled')
|
||||
ret.update({'comment': comt})
|
||||
comment = 'Plugin \'some_plugin\' is already disabled.'
|
||||
ret.update({'comment': comment})
|
||||
self.assertDictEqual(rabbitmq_plugin.disabled(name), ret)
|
||||
|
||||
with patch.dict(rabbitmq_plugin.__opts__, {'test': True}):
|
||||
comt = ('Plugin some_plugin is set to be disabled')
|
||||
ret.update({'comment': comt, 'result': None})
|
||||
comment = 'Plugin \'some_plugin\' is set to be disabled.'
|
||||
changes = {'new': '', 'old': 'some_plugin'}
|
||||
ret.update({'comment': comment, 'result': None, 'changes': changes})
|
||||
self.assertDictEqual(rabbitmq_plugin.disabled(name), ret)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue