mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
247: Added unit tests for errors.RequirementError
This commit is contained in:
parent
004e989dc4
commit
296d59d27a
@ -19,6 +19,8 @@
|
||||
|
||||
"""
|
||||
All custom errors raised by `ipalib` package.
|
||||
|
||||
Also includes a few utility functions for raising exceptions.
|
||||
"""
|
||||
|
||||
TYPE_FORMAT = '%s: need a %r; got %r'
|
||||
@ -155,16 +157,13 @@ class RequirementError(ValidationError):
|
||||
Raised when a required option was not provided.
|
||||
"""
|
||||
def __init__(self, name):
|
||||
ValidationError.__init__(self, name, None,
|
||||
'missing required value'
|
||||
)
|
||||
ValidationError.__init__(self, name, None, 'Required')
|
||||
|
||||
|
||||
class SetError(IPAError):
|
||||
msg = 'setting %r, but NameSpace does not allow attribute setting'
|
||||
|
||||
|
||||
|
||||
class RegistrationError(IPAError):
|
||||
"""
|
||||
Base class for errors that occur during plugin registration.
|
||||
|
@ -251,3 +251,24 @@ class test_RuleError(ClassChecker):
|
||||
assert e.rule is my_rule
|
||||
# Check that index default is None:
|
||||
assert self.cls(name, value, error, my_rule).index is None
|
||||
|
||||
|
||||
class test_RequirementError(ClassChecker):
|
||||
"""
|
||||
Tests the `errors.RequirementError` exception.
|
||||
"""
|
||||
_cls = errors.RequirementError
|
||||
|
||||
def test_class(self):
|
||||
assert self.cls.__bases__ == (errors.ValidationError,)
|
||||
|
||||
def test_init(self):
|
||||
"""
|
||||
Tests the `errors.RequirementError.__init__` method.
|
||||
"""
|
||||
name = 'givenname'
|
||||
e = self.cls(name)
|
||||
assert e.name is name
|
||||
assert e.value is None
|
||||
assert e.error == 'Required'
|
||||
assert e.index is None
|
||||
|
Loading…
Reference in New Issue
Block a user