2012-08-04 22:07:39 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
tests.integration.shell.call
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
:copyright: © 2012 UfSoft.org - :email:`Pedro Algarvio (pedro@algarvio.me)`
|
|
|
|
:license: Apache 2.0, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# Import salt libs
|
2012-11-16 00:07:08 +00:00
|
|
|
from salt import version
|
2012-09-30 09:59:07 +00:00
|
|
|
from saltunittest import TestLoader, TextTestRunner, skipIf
|
2012-08-04 22:07:39 +00:00
|
|
|
import integration
|
|
|
|
from integration import TestDaemon
|
|
|
|
|
|
|
|
|
|
|
|
class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|
|
|
|
|
|
|
_call_binary_ = 'salt-call'
|
|
|
|
|
2012-08-13 06:10:42 +00:00
|
|
|
def test_default_output(self):
|
|
|
|
out = self.run_call('test.fib 3')
|
2012-10-30 20:37:13 +00:00
|
|
|
expect = ['local: !!python/tuple',
|
|
|
|
'- - 0',
|
|
|
|
' - 1',
|
|
|
|
' - 1',
|
2012-11-04 10:29:07 +00:00
|
|
|
' - 2']
|
|
|
|
self.assertEqual(expect, out[:-1])
|
2012-08-13 06:10:42 +00:00
|
|
|
|
|
|
|
def test_text_output(self):
|
|
|
|
out = self.run_call('--text-out test.fib 3')
|
2012-11-16 00:07:08 +00:00
|
|
|
if version.__version_info__ < (0, 10, 8):
|
|
|
|
expect = [
|
|
|
|
"WARNING: The option --text-out is deprecated. Please "
|
|
|
|
"consider using '--out text' instead."
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
expect = []
|
|
|
|
|
|
|
|
expect += [
|
|
|
|
'local: ([0, 1, 1, 2]'
|
|
|
|
]
|
|
|
|
|
|
|
|
self.assertEqual(''.join(expect), ''.join(out).rsplit(",", 1)[0])
|
2012-08-13 06:10:42 +00:00
|
|
|
|
2012-09-30 09:59:07 +00:00
|
|
|
@skipIf(sys.platform.startswith('win'), 'This test does not apply on Win')
|
|
|
|
def test_user_delete_kw_output(self):
|
|
|
|
ret = self.run_call('-d user.delete')
|
|
|
|
self.assertIn(
|
|
|
|
'salt \'*\' user.delete name remove=True force=True',
|
|
|
|
''.join(ret)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2012-08-04 22:07:39 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
loader = TestLoader()
|
|
|
|
tests = loader.loadTestsFromTestCase(CallTest)
|
|
|
|
print('Setting up Salt daemons to execute tests')
|
|
|
|
with TestDaemon():
|
|
|
|
runner = TextTestRunner(verbosity=1).run(tests)
|
2012-09-30 09:59:07 +00:00
|
|
|
sys.exit(runner.wasSuccessful())
|