2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2014-11-21 19:05:13 +00:00
|
|
|
# Import Python libs
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-06-27 10:57:33 +00:00
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
2013-06-25 08:24:45 +00:00
|
|
|
# Import salt libs
|
2013-06-27 10:57:33 +00:00
|
|
|
import integration
|
2013-06-14 22:17:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DecoratorTest(integration.ModuleCase):
|
|
|
|
def test_module(self):
|
2013-06-20 17:10:14 +00:00
|
|
|
self.assertTrue(
|
|
|
|
self.run_function(
|
|
|
|
'runtests_decorators.working_function'
|
|
|
|
)
|
|
|
|
)
|
2013-06-14 22:17:06 +00:00
|
|
|
|
2013-06-20 17:22:59 +00:00
|
|
|
def not_test_depends(self):
|
2013-06-20 17:10:14 +00:00
|
|
|
ret = self.run_function('runtests_decorators.depends')
|
|
|
|
self.assertTrue(ret['ret'])
|
2015-04-21 13:02:17 +00:00
|
|
|
self.assertTrue(isinstance(ret['time'], float))
|
2013-06-14 22:17:06 +00:00
|
|
|
|
|
|
|
def test_missing_depends(self):
|
2013-06-20 17:10:14 +00:00
|
|
|
self.assertIn(
|
|
|
|
'is not available',
|
|
|
|
self.run_function('runtests_decorators.missing_depends'
|
|
|
|
)
|
|
|
|
)
|
2013-06-14 22:17:06 +00:00
|
|
|
|
2015-03-06 05:59:10 +00:00
|
|
|
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'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2013-06-20 17:22:59 +00:00
|
|
|
def not_test_depends_will_fallback(self):
|
2013-06-20 17:10:14 +00:00
|
|
|
ret = self.run_function('runtests_decorators.depends_will_fallback')
|
|
|
|
self.assertTrue(ret['ret'])
|
2015-04-21 13:02:17 +00:00
|
|
|
self.assertTrue(isinstance(ret['time'], float))
|
2013-06-14 22:17:06 +00:00
|
|
|
|
2013-06-20 17:10:14 +00:00
|
|
|
def test_missing_depends_again(self):
|
|
|
|
self.assertIn(
|
|
|
|
'fallback',
|
|
|
|
self.run_function(
|
|
|
|
'runtests_decorators.missing_depends_will_fallback'
|
|
|
|
)
|
|
|
|
)
|
2013-06-14 22:17:06 +00:00
|
|
|
|
2013-06-25 08:24:45 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(DecoratorTest)
|