|
|
@ -39,65 +39,65 @@ class TestModArgsDwim(unittest.TestCase):
|
|
|
|
def test_basic_shell(self):
|
|
|
|
def test_basic_shell(self):
|
|
|
|
mod, args, to = self.m.parse(dict(shell='echo hi'))
|
|
|
|
mod, args, to = self.m.parse(dict(shell='echo hi'))
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
assert mod == 'command'
|
|
|
|
self.assertEqual(mod, 'command')
|
|
|
|
assert args == dict(
|
|
|
|
self.assertEqual(args, dict(
|
|
|
|
_raw_params = 'echo hi',
|
|
|
|
_raw_params = 'echo hi',
|
|
|
|
_uses_shell = True,
|
|
|
|
_uses_shell = True,
|
|
|
|
)
|
|
|
|
))
|
|
|
|
assert to is None
|
|
|
|
assert to is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_basic_command(self):
|
|
|
|
def test_basic_command(self):
|
|
|
|
mod, args, to = self.m.parse(dict(command='echo hi'))
|
|
|
|
mod, args, to = self.m.parse(dict(command='echo hi'))
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
assert mod == 'command'
|
|
|
|
self.assertEqual(mod, 'command')
|
|
|
|
assert args == dict(
|
|
|
|
self.assertEqual(args, dict(
|
|
|
|
_raw_params = 'echo hi',
|
|
|
|
_raw_params = 'echo hi',
|
|
|
|
)
|
|
|
|
))
|
|
|
|
assert to is None
|
|
|
|
assert to is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_shell_with_modifiers(self):
|
|
|
|
def test_shell_with_modifiers(self):
|
|
|
|
mod, args, to = self.m.parse(dict(shell='/bin/foo creates=/tmp/baz removes=/tmp/bleep'))
|
|
|
|
mod, args, to = self.m.parse(dict(shell='/bin/foo creates=/tmp/baz removes=/tmp/bleep'))
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
assert mod == 'command'
|
|
|
|
self.assertEqual(mod, 'command')
|
|
|
|
assert args == dict(
|
|
|
|
self.assertEqual(args, dict(
|
|
|
|
creates = '/tmp/baz',
|
|
|
|
creates = '/tmp/baz',
|
|
|
|
removes = '/tmp/bleep',
|
|
|
|
removes = '/tmp/bleep',
|
|
|
|
_raw_params = '/bin/foo',
|
|
|
|
_raw_params = '/bin/foo',
|
|
|
|
_uses_shell = True,
|
|
|
|
_uses_shell = True,
|
|
|
|
)
|
|
|
|
))
|
|
|
|
assert to is None
|
|
|
|
assert to is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_normal_usage(self):
|
|
|
|
def test_normal_usage(self):
|
|
|
|
mod, args, to = self.m.parse(dict(copy='src=a dest=b'))
|
|
|
|
mod, args, to = self.m.parse(dict(copy='src=a dest=b'))
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
assert mod == 'copy'
|
|
|
|
self.assertEqual(mod, 'copy')
|
|
|
|
assert args == dict(src='a', dest='b')
|
|
|
|
self.assertEqual(args, dict(src='a', dest='b'))
|
|
|
|
assert to is None
|
|
|
|
assert to is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_complex_args(self):
|
|
|
|
def test_complex_args(self):
|
|
|
|
mod, args, to = self.m.parse(dict(copy=dict(src='a', dest='b')))
|
|
|
|
mod, args, to = self.m.parse(dict(copy=dict(src='a', dest='b')))
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
assert mod == 'copy'
|
|
|
|
self.assertEqual(mod, 'copy')
|
|
|
|
assert args == dict(src='a', dest='b')
|
|
|
|
self.assertEqual(args, dict(src='a', dest='b'))
|
|
|
|
assert to is None
|
|
|
|
assert to is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_action_with_complex(self):
|
|
|
|
def test_action_with_complex(self):
|
|
|
|
mod, args, to = self.m.parse(dict(action=dict(module='copy', src='a', dest='b')))
|
|
|
|
mod, args, to = self.m.parse(dict(action=dict(module='copy', src='a', dest='b')))
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
assert mod == 'copy'
|
|
|
|
self.assertEqual(mod, 'copy')
|
|
|
|
assert args == dict(src='a', dest='b')
|
|
|
|
self.assertEqual(args, dict(src='a', dest='b'))
|
|
|
|
assert to is None
|
|
|
|
assert to is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_action_with_complex_and_complex_args(self):
|
|
|
|
def test_action_with_complex_and_complex_args(self):
|
|
|
|
mod, args, to = self.m.parse(dict(action=dict(module='copy', args=dict(src='a', dest='b'))))
|
|
|
|
mod, args, to = self.m.parse(dict(action=dict(module='copy', args=dict(src='a', dest='b'))))
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
assert mod == 'copy'
|
|
|
|
self.assertEqual(mod, 'copy')
|
|
|
|
assert args == dict(src='a', dest='b')
|
|
|
|
self.assertEqual(args, dict(src='a', dest='b'))
|
|
|
|
assert to is None
|
|
|
|
assert to is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_local_action_string(self):
|
|
|
|
def test_local_action_string(self):
|
|
|
|
mod, args, to = self.m.parse(dict(local_action='copy src=a dest=b'))
|
|
|
|
mod, args, to = self.m.parse(dict(local_action='copy src=a dest=b'))
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
self._debug(mod, args, to)
|
|
|
|
assert mod == 'copy'
|
|
|
|
self.assertEqual(mod, 'copy')
|
|
|
|
assert args == dict(src='a', dest='b')
|
|
|
|
self.assertEqual(args, dict(src='a', dest='b'))
|
|
|
|
assert to is 'localhost'
|
|
|
|
assert to is 'localhost'
|
|
|
|