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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user