Removes whitespace from CLI queries

Strips leading and trailing whitespaces
from CLI query field and value parameter
before building url.

Closes-Bug: 1464694

Change-Id: Ibe99747e22afe05eee187d59aaf0603f58e91373
This commit is contained in:
Rohit Jaiswal
2015-06-16 19:45:50 +00:00
parent 6add8c4fbf
commit 1f12c62301
2 changed files with 15 additions and 1 deletions

View File

@@ -237,3 +237,17 @@ class CliTest(utils.BaseTestCase):
'type': 'datetime',
'value': '2014-03-11T16:02:58'}],
ar)
def test_with_whitespace(self):
ar = options.cli_to_array('start_timestamp= 2015-01-01T00:00:00;'
' end_timestamp =2015-06-20T14:01:59 ')
self.assertEqual([{'field': 'start_timestamp',
'op': 'eq',
'type': '',
'value': '2015-01-01T00:00:00'},
{'field': 'end_timestamp',
'op': 'eq',
'type': '',
'value': '2015-06-20T14:01:59'}],
ar)

View File

@@ -99,7 +99,7 @@ def cli_to_array(cli_query):
if not len(value):
_value_error('value')
return field, operator, value
return field.strip(), operator, value.strip()
def split_by_data_type(query_value):
frags = DATA_TYPE_RE.match(query_value)