summaryrefslogtreecommitdiffstats
path: root/ipalib/tests/test_public.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-09-04 02:02:06 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-09-04 02:02:06 +0000
commit5cdb182ae8e87f4d3e84bbf7875357c101ca605e (patch)
treeb5c9b23c8738faec92dba4759bf24ffa05514a73 /ipalib/tests/test_public.py
parent7e3664a964e6c0ef0c773ae8eb3ab3ac21385649 (diff)
downloadfreeipa.git-5cdb182ae8e87f4d3e84bbf7875357c101ca605e.tar.gz
freeipa.git-5cdb182ae8e87f4d3e84bbf7875357c101ca605e.tar.xz
freeipa.git-5cdb182ae8e87f4d3e84bbf7875357c101ca605e.zip
251: Fixed Command.validate() so it raises RequirementError; updated and re-enabled unit tests for Command.validate()
Diffstat (limited to 'ipalib/tests/test_public.py')
-rw-r--r--ipalib/tests/test_public.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py
index 0b2ded96..012b6253 100644
--- a/ipalib/tests/test_public.py
+++ b/ipalib/tests/test_public.py
@@ -329,7 +329,7 @@ class test_Command(ClassChecker):
def __call__(self, value):
if value != self.name:
- return 'must equal %r' % self.name
+ return 'must equal %s' % self.name
default_from = public.DefaultFrom(
lambda arg: arg,
@@ -420,7 +420,7 @@ class test_Command(ClassChecker):
assert sub.get_default(**no_fill) == {}
assert sub.get_default(**fill) == default
- def dont_validate(self):
+ def test_validate(self):
"""
Tests the `public.Command.validate` method.
"""
@@ -438,17 +438,21 @@ class test_Command(ClassChecker):
# Check with an invalid arg
fail = dict(okay)
- fail['option0'] = 'whatever'
- raises(errors.RuleError, sub.validate, **fail)
+ fail['option0'] = u'whatever'
+ e = raises(errors.RuleError, sub.validate, **fail)
+ assert e.name == 'option0'
+ assert e.value == u'whatever'
+ assert e.error == 'must equal option0'
+ assert e.rule.__class__.__name__ == 'Rule'
+ assert e.index is None
# Check with a missing required arg
fail = dict(okay)
fail.pop('option1')
- raises(errors.RequirementError, sub.validate, **fail)
-
- # Check with missing *not* required arg
- okay.pop('option0')
- sub.validate(**okay)
+ e = raises(errors.RequirementError, sub.validate, **fail)
+ assert e.name == 'option1'
+ assert e.value is None
+ assert e.index is None
def test_execute(self):
"""