salt/tests/integration/modules/state.py

59 lines
1.7 KiB
Python
Raw Normal View History

# Import python libs
import sys
2012-03-29 23:18:32 +00:00
# Import salt libs
from saltunittest import TestLoader, TextTestRunner
2012-03-29 23:18:32 +00:00
import integration
from integration import TestDaemon
2012-03-29 23:18:32 +00:00
class StateModuleTest(integration.ModuleCase):
'''
Validate the test module
'''
def test_show_highstate(self):
'''
state.show_highstate
'''
high = self.run_function('state.show_highstate')
self.assertTrue(isinstance(high, dict))
self.assertTrue('/testfile' in high)
self.assertEqual(high['/testfile']['__env__'], 'base')
def test_show_lowstate(self):
'''
state.show_lowstate
'''
low = self.run_function('state.show_lowstate')
self.assertTrue(isinstance(low, list))
self.assertTrue(isinstance(low[0], dict))
2012-05-14 03:31:46 +00:00
def test_catch_recurse(self):
'''
state.show_sls used to catch a recursive ref
'''
err = self.run_function('state.sls', mods='recurse_fail')
self.assertIn('recursive', err[0])
2012-05-14 03:31:46 +00:00
2012-06-16 04:41:36 +00:00
def test_no_recurse(self):
'''
2012-06-19 16:29:14 +00:00
verify that a sls structure is NOT a recursive ref
2012-06-16 04:41:36 +00:00
'''
sls = self.run_function('state.show_sls', mods='recurse_ok')
self.assertIn('snmpd', sls)
2012-06-19 16:29:14 +00:00
def test_no_recurse_two(self):
'''
verify that a sls structure is NOT a recursive ref
'''
sls = self.run_function('state.show_sls', mods='recurse_ok_two')
self.assertIn('/etc/nagios/nrpe.cfg', sls)
if __name__ == "__main__":
loader = TestLoader()
tests = loader.loadTestsFromTestCase(StateModuleTest)
print('Setting up Salt daemons to execute tests')
with TestDaemon():
runner = TextTestRunner(verbosity=1).run(tests)
sys.exit(runner.wasSuccessful())