From fa50c1a7dcfd20308e20632efa0c1c9d6068a631 Mon Sep 17 00:00:00 2001 From: 00129207 Date: Tue, 18 Jul 2017 10:15:12 +0800 Subject: [PATCH] Add uts for parse_command Change-Id: I8d1393f4d8bc39d14047517317a43fedca84a6d9 --- zunclient/tests/unit/common/test_utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/zunclient/tests/unit/common/test_utils.py b/zunclient/tests/unit/common/test_utils.py index 1c7b2dac..b7824762 100644 --- a/zunclient/tests/unit/common/test_utils.py +++ b/zunclient/tests/unit/common/test_utils.py @@ -244,3 +244,21 @@ class ParseNetsTest(test_utils.BaseTestCase): nets = ['network=1234567, v4-fixed-ip=23.555.567,789'] self.assertRaises(exc.CommandError, utils.parse_nets, nets) + + +class ParseCommandTest(test_utils.BaseTestCase): + + def test_no_command(self): + command = [] + result = utils.parse_command(command) + self.assertEqual('', result) + + def test_command_ls(self): + command = ['ls', '-al'] + result = utils.parse_command(command) + self.assertEqual('"ls" "-al"', result) + + def test_command_echo_hello(self): + command = ['sh', '-c', 'echo hello'] + result = utils.parse_command(command) + self.assertEqual('"sh" "-c" "echo hello"', result)