diff options
author | Petr Viktorin <pviktori@redhat.com> | 2012-02-23 07:29:47 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-03-20 20:03:54 -0400 |
commit | dddebe23507749486fb09d219f0da4f483ba4e79 (patch) | |
tree | 968e860043b04097a40d939f5e39c404b519a378 /tests/test_ipalib/test_parameters.py | |
parent | 8f71f42ef7c7c67c0d0ee47814715e2c023d95ce (diff) | |
download | freeipa-dddebe23507749486fb09d219f0da4f483ba4e79.tar.gz freeipa-dddebe23507749486fb09d219f0da4f483ba4e79.tar.xz freeipa-dddebe23507749486fb09d219f0da4f483ba4e79.zip |
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
Diffstat (limited to 'tests/test_ipalib/test_parameters.py')
-rw-r--r-- | tests/test_ipalib/test_parameters.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/test_ipalib/test_parameters.py b/tests/test_ipalib/test_parameters.py index ad8d84044..83c33ddfc 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 |