salt/tests/integration/modules/test_decorators.py

60 lines
1.9 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# Import Python libs
2018-01-21 20:08:08 +00:00
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Testing libs
from tests.support.case import ModuleCase
class DecoratorTest(ModuleCase):
def test_module(self):
2013-06-20 17:10:14 +00:00
self.assertTrue(
self.run_function(
'runtests_decorators.working_function'
)
)
2015-10-23 14:06:35 +00:00
def test_depends(self):
2013-06-20 17:10:14 +00:00
ret = self.run_function('runtests_decorators.depends')
2015-10-23 14:06:35 +00:00
self.assertTrue(isinstance(ret, dict))
2013-06-20 17:10:14 +00:00
self.assertTrue(ret['ret'])
2015-04-21 13:02:17 +00:00
self.assertTrue(isinstance(ret['time'], float))
def test_missing_depends(self):
self.assertEqual(
{'runtests_decorators.missing_depends_will_fallback': '\n CLI Example:\n\n ',
'runtests_decorators.missing_depends': "'runtests_decorators.missing_depends' is not available."},
2013-06-20 17:10:14 +00:00
self.run_function('runtests_decorators.missing_depends'
)
)
def test_bool_depends(self):
# test True
self.assertTrue(
self.run_function(
'runtests_decorators.booldependsTrue'
)
)
# test False
self.assertIn(
'is not available',
self.run_function('runtests_decorators.booldependsFalse'
)
)
2015-10-23 14:06:35 +00:00
def test_depends_will_not_fallback(self):
ret = self.run_function('runtests_decorators.depends_will_not_fallback')
self.assertTrue(isinstance(ret, dict))
2013-06-20 17:10:14 +00:00
self.assertTrue(ret['ret'])
2015-04-21 13:02:17 +00:00
self.assertTrue(isinstance(ret['time'], float))
2015-10-23 14:06:35 +00:00
def test_missing_depends_will_fallback(self):
self.assertListEqual(
[False, 'fallback'],
2013-06-20 17:10:14 +00:00
self.run_function(
'runtests_decorators.missing_depends_will_fallback'
)
)