diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-27 23:40:34 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-27 23:40:34 +0000 |
commit | 5da1d4bb86fadc12e2becf05239b0177d42ce454 (patch) | |
tree | 0c0e8d10cf62388c0cf2c9d3c9fe60e6bbd8f8e4 /ipalib/tests | |
parent | 8fbc01ca864df332afe16ed51ea661ae88892d8b (diff) | |
download | freeipa.git-5da1d4bb86fadc12e2becf05239b0177d42ce454.tar.gz freeipa.git-5da1d4bb86fadc12e2becf05239b0177d42ce454.tar.xz freeipa.git-5da1d4bb86fadc12e2becf05239b0177d42ce454.zip |
207: Added Unicode.validate() method and corresponding unit tests
Diffstat (limited to 'ipalib/tests')
-rw-r--r-- | ipalib/tests/test_ipa_types.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ipalib/tests/test_ipa_types.py b/ipalib/tests/test_ipa_types.py index d78160db..71d8d6f3 100644 --- a/ipalib/tests/test_ipa_types.py +++ b/ipalib/tests/test_ipa_types.py @@ -136,9 +136,13 @@ class test_Int(ClassChecker): class test_Unicode(ClassChecker): _cls = ipa_types.Unicode + def test_class(self): + assert self.cls.__bases__ == (ipa_types.Type,) + assert self.cls.type is unicode + def test_init(self): o = self.cls() - assert o.name == 'Unicode' + assert read_only(o, 'name') == 'Unicode' assert o.min_length is None assert o.max_length is None assert o.pattern is None @@ -219,3 +223,14 @@ class test_Unicode(ClassChecker): assert m.group(1) == value for value in ('hello beautiful', 'world!'): assert o.regex.match(value) is None + + def test_validate(self): + pat = '^a_*b$' + o = self.cls(min_length=3, max_length=4, pattern=pat) + assert o.validate(u'a_b') is None + assert o.validate(u'a__b') is None + assert o.validate('a_b') == 'Must be a string' + assert o.validate(u'ab') == 'Must be at least 3 characters long' + assert o.validate(u'a___b') == 'Can be at most 4 characters long' + assert o.validate(u'a-b') == 'Must match %r' % pat + assert o.validate(u'a--b') == 'Must match %r' % pat |