|
|
|
@ -49,32 +49,35 @@ class Exec(unittest.TestCase): |
|
|
|
|
false_fd.writelines(["#!/bin/sh\n", "/bin/false"]) |
|
|
|
|
false_fd.close() |
|
|
|
|
|
|
|
|
|
target_host = "does.not.exist" |
|
|
|
|
remote_exec = "ssh -o User=root -q" |
|
|
|
|
remote_copy = "scp -o User=root -q" |
|
|
|
|
self.wrapper = cdist.exec.Wrapper(target_host, remote_exec, remote_copy) |
|
|
|
|
|
|
|
|
|
def tearDown(self): |
|
|
|
|
shutil.rmtree(self.temp_dir) |
|
|
|
|
|
|
|
|
|
def test_local_success_shell(self): |
|
|
|
|
try: |
|
|
|
|
cdist.exec.shell_run_or_debug_fail(self.shell_true, [self.shell_true]) |
|
|
|
|
self.wrapper.shell_run_or_debug_fail(self.shell_true, [self.shell_true]) |
|
|
|
|
except cdist.Error: |
|
|
|
|
failed = True |
|
|
|
|
else: |
|
|
|
|
failed = False |
|
|
|
|
|
|
|
|
|
self.assertFalse(failed) |
|
|
|
|
|
|
|
|
|
def test_local_fail_shell(self): |
|
|
|
|
self.assertRaises(cdist.Error, cdist.exec.shell_run_or_debug_fail, |
|
|
|
|
self.assertRaises(cdist.Error, self.wrapper.shell_run_or_debug_fail, |
|
|
|
|
self.shell_false, [self.shell_false]) |
|
|
|
|
|
|
|
|
|
def test_local_success(self): |
|
|
|
|
try: |
|
|
|
|
cdist.exec.run_or_fail(["/bin/true"]) |
|
|
|
|
self.wrapper.run_or_fail(["/bin/true"]) |
|
|
|
|
except cdist.Error: |
|
|
|
|
failed = True |
|
|
|
|
else: |
|
|
|
|
failed = False |
|
|
|
|
|
|
|
|
|
self.assertFalse(failed) |
|
|
|
|
|
|
|
|
|
def test_local_fail(self): |
|
|
|
|
self.assertRaises(cdist.Error, cdist.exec.run_or_fail, ["/bin/false"]) |
|
|
|
|
self.assertRaises(cdist.Error, self.wrapper.run_or_fail, ["/bin/false"]) |
|
|
|
|