summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2010-12-06 15:09:03 -0500
committerRob Crittenden <rcritten@redhat.com>2010-12-07 16:37:42 -0500
commit6e2dd0fa5b79849c3dbd5f9b855e43b634e2a4b3 (patch)
tree3264b8ba10fdb44845ee4f257e851f2764f3a6cd /tests
parent78786a699586b12ec53c0a87703e0a44e9c7427e (diff)
downloadfreeipa-6e2dd0fa5b79849c3dbd5f9b855e43b634e2a4b3.tar.gz
freeipa-6e2dd0fa5b79849c3dbd5f9b855e43b634e2a4b3.tar.xz
freeipa-6e2dd0fa5b79849c3dbd5f9b855e43b634e2a4b3.zip
Add new parameter type IA5Str and use this to enforce the right charset.
ticket 496
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ipalib/test_parameters.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_ipalib/test_parameters.py b/tests/test_ipalib/test_parameters.py
index 01cb8f753..996d9af29 100644
--- a/tests/test_ipalib/test_parameters.py
+++ b/tests/test_ipalib/test_parameters.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Authors:
# Jason Gerard DeRose <jderose@redhat.com>
#
@@ -1437,3 +1438,25 @@ def test_messages():
continue
assert type(attr.type_error) is str
assert attr.type_error in parameters.__messages
+
+
+class test_IA5Str(ClassChecker):
+ """
+ Test the `ipalib.parameters.IA5Str` class.
+ """
+ _cls = parameters.IA5Str
+
+ def test_convert_scalar(self):
+ """
+ Test the `ipalib.parameters.IA5Str._convert_scalar` method.
+ """
+ o = self.cls('my_str')
+ mthd = o._convert_scalar
+ for value in (u'Hello', 42, 1.2):
+ assert mthd(value) == unicode(value)
+ bad = ['HelloĆ”']
+ for value in bad:
+ e = raises(errors.ConversionError, mthd, value)
+ assert e.name == 'my_str'
+ assert e.index is None
+ assert_equal(e.error, "The character \''\\xc3'\' is not allowed.")