From dddebe23507749486fb09d219f0da4f483ba4e79 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 23 Feb 2012 07:29:47 -0500 Subject: Only split CSV in the client, quote instead of escaping Splitting on commas is not an idempotent operation: 'a,b\,c' -> ('a', 'b,c') -> ('a', 'b', 'c') That means we can't do it when the call is forwarded, so this is only done on the CLI. The UI already sends values as a tuple. Replace escaping in the csv parser with quoting. Quoted strings can have embedded commas instead of having to escape them. This prevents the csv parser from eating all escape characters. Also, document Param's csv arguments, and update tests. https://fedorahosted.org/freeipa/ticket/2417 https://fedorahosted.org/freeipa/ticket/2227 --- tests/test_ipalib/test_parameters.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/test_ipalib/test_parameters.py') diff --git a/tests/test_ipalib/test_parameters.py b/tests/test_ipalib/test_parameters.py index ad8d8404..83c33ddf 100644 --- a/tests/test_ipalib/test_parameters.py +++ b/tests/test_ipalib/test_parameters.py @@ -635,44 +635,44 @@ class test_Param(ClassChecker): assert o._convert_scalar.value is default assert o.normalizer.value is default - def test_csv_normalize(self): + def test_split_csv(self): """ - Test the `ipalib.parameters.Param.normalize` method with csv. + Test the `ipalib.parameters.Param.split_csv` method with csv. """ o = self.cls('my_list+', csv=True) - n = o.normalize('a,b') + n = o.split_csv('a,b') assert type(n) is tuple assert len(n) is 2 - n = o.normalize('bar, "hi, there",foo') + n = o.split_csv('bar, "hi, there",foo') assert type(n) is tuple assert len(n) is 3 - def test_csv_normalize_separator(self): + def test_split_csv_separator(self): """ - Test the `ipalib.parameters.Param.normalize` method with csv and a separator. + Test the `ipalib.parameters.Param.split_csv` method with csv and a separator. """ o = self.cls('my_list+', csv=True, csv_separator='|') - n = o.normalize('a') + n = o.split_csv('a') assert type(n) is tuple assert len(n) is 1 - n = o.normalize('a|b') + n = o.split_csv('a|b') assert type(n) is tuple assert len(n) is 2 - def test_csv_normalize_skipspace(self): + def test_split_csv_skipspace(self): """ - Test the `ipalib.parameters.Param.normalize` method with csv without skipping spaces. + Test the `ipalib.parameters.Param.split_csv` method with csv without skipping spaces. """ o = self.cls('my_list+', csv=True, csv_skipspace=False) - n = o.normalize('a') + n = o.split_csv('a') assert type(n) is tuple assert len(n) is 1 - n = o.normalize('a, "b,c", d') + n = o.split_csv('a, "b,c", d') assert type(n) is tuple # the output w/o skipspace is ['a',' "b','c"',' d'] assert len(n) is 4 -- cgit