summaryrefslogtreecommitdiffstats
path: root/tests/test_ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2009-03-18 15:44:53 -0400
committerRob Crittenden <rcritten@redhat.com>2009-03-20 09:29:44 -0400
commita8a2664190eb6f2604d4753b4af8a599a4e24c4b (patch)
treedbe68c5980bc61621fedc5f9d54a3f27f45d85b9 /tests/test_ipalib
parentc39a29e0cf72a7f7629e3bdaaa2efc49337cb727 (diff)
downloadfreeipa-a8a2664190eb6f2604d4753b4af8a599a4e24c4b.tar.gz
freeipa-a8a2664190eb6f2604d4753b4af8a599a4e24c4b.tar.xz
freeipa-a8a2664190eb6f2604d4753b4af8a599a4e24c4b.zip
Add new type List that converts delimited values into a tuple
Diffstat (limited to 'tests/test_ipalib')
-rw-r--r--tests/test_ipalib/test_parameters.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/test_ipalib/test_parameters.py b/tests/test_ipalib/test_parameters.py
index 472386da3..82f39a32d 100644
--- a/tests/test_ipalib/test_parameters.py
+++ b/tests/test_ipalib/test_parameters.py
@@ -1226,6 +1226,65 @@ class test_Float(ClassChecker):
dummy.reset()
+class test_List(ClassChecker):
+ """
+ Test the `ipalib.parameters.List` class.
+ """
+ _cls = parameters.List
+
+ def test_init(self):
+ """
+ Test the `ipalib.parameters.List.__init__` method.
+ """
+ # Test with no kwargs:
+ o = self.cls('my_list')
+ assert o.type is tuple
+ assert isinstance(o, parameters.List)
+ assert o.multivalue is True
+ assert o.skipspace is True
+
+ def test_normalize(self):
+ """
+ Test the `ipalib.parameters.List.normalize` method.
+ """
+ o = self.cls('my_list')
+ n = o.normalize('a,b')
+ assert type(n) is tuple
+ assert len(n) is 2
+
+ n = o.normalize('bar, "hi, there",foo')
+ assert type(n) is tuple
+ assert len(n) is 3
+
+ def test_normalize_separator(self):
+ """
+ Test the `ipalib.parameters.List.normalize` method with a separator.
+ """
+ o = self.cls('my_list', separator='|')
+
+ n = o.normalize('a')
+ assert type(n) is tuple
+ assert len(n) is 1
+
+ n = o.normalize('a|b')
+ assert type(n) is tuple
+ assert len(n) is 2
+
+ def test_normalize_skipspace(self):
+ """
+ Test the `ipalib.parameters.List.normalize` method without skipping spaces.
+ """
+ o = self.cls('my_list', skipspace=False)
+
+ n = o.normalize('a')
+ assert type(n) is tuple
+ assert len(n) is 1
+
+ n = o.normalize('a, "b,c", d')
+ assert type(n) is tuple
+ # the output w/o skipspace is ['a',' "b','c"',' d']
+ assert len(n) is 4
+
def test_create_param():
"""
Test the `ipalib.parameters.create_param` function.