From 6c704e4a12715ccc09f7feff0a9c2030c74f2c97 Mon Sep 17 00:00:00 2001 From: Alexander Saprykin Date: Thu, 6 Aug 2015 12:15:09 +0300 Subject: [PATCH] Fix incorrect cmdline parsing in BaseCLITest str.split replaced with shlex.split in exec_command method. BaseCLITest.exec_command fails if passed command line string contains arguments with spaces, since str.split is used to split arguments from string to argv list. Change-Id: Ib5558d1787044399718f36d34e6d7a5e5e331fb3 Closes-Bug: #1482133 --- fuelclient/tests/v2/unit/cli/test_engine.py | 3 ++- fuelclient/tests/v2/unit/cli/test_node.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fuelclient/tests/v2/unit/cli/test_engine.py b/fuelclient/tests/v2/unit/cli/test_engine.py index 0c08f3de..5ba048fa 100644 --- a/fuelclient/tests/v2/unit/cli/test_engine.py +++ b/fuelclient/tests/v2/unit/cli/test_engine.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +import shlex import sys import mock @@ -48,7 +49,7 @@ class BaseCLITest(base.UnitTestCase): def exec_command(self, command=''): """Executes fuelclient with the specified arguments.""" - return main_mod.main(argv=command.split()) + return main_mod.main(argv=shlex.split(command)) def exec_command_interactive(self, commands): """Executes specified commands in one sesstion of interactive mode diff --git a/fuelclient/tests/v2/unit/cli/test_node.py b/fuelclient/tests/v2/unit/cli/test_node.py index 25ef4f83..c6619bd1 100644 --- a/fuelclient/tests/v2/unit/cli/test_node.py +++ b/fuelclient/tests/v2/unit/cli/test_node.py @@ -91,13 +91,13 @@ class TestNodeCommand(test_engine.BaseCLITest): self.m_client.get_node_vms_conf.assert_called_once_with(node_id) def test_node_vms_conf_create(self): - vms_conf = """{"id":2} {"id":3}""" + vms_conf = r'{\"id\":2} {\"id\":3}' config = [{'id': 2}, {'id': 3}] node_id = 42 - args = "node create-vms-conf {0} --conf {1}".format( + args = 'node create-vms-conf {0} --conf {1}'.format( node_id, vms_conf) self.exec_command(args)