diff options
author | Pavel Zuna <pzuna@redhat.com> | 2009-08-27 15:55:19 +0200 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-10-05 15:59:09 -0400 |
commit | e01b1b8f99e67b08d1827b13f411f6d3cccfcf41 (patch) | |
tree | 674f392b669e5d5e46bc30dde550926494cfce4b /tests/test_ipalib | |
parent | 1e48662b9ba623ebd8ad62035c9c84dc4f1fed70 (diff) | |
download | freeipa-e01b1b8f99e67b08d1827b13f411f6d3cccfcf41.tar.gz freeipa-e01b1b8f99e67b08d1827b13f411f6d3cccfcf41.tar.xz freeipa-e01b1b8f99e67b08d1827b13f411f6d3cccfcf41.zip |
Fix unit tests for plugins using baseldap classes.
Diffstat (limited to 'tests/test_ipalib')
-rw-r--r-- | tests/test_ipalib/test_crud.py | 134 | ||||
-rw-r--r-- | tests/test_ipalib/test_frontend.py | 1 | ||||
-rw-r--r-- | tests/test_ipalib/test_parameters.py | 17 |
3 files changed, 9 insertions, 143 deletions
diff --git a/tests/test_ipalib/test_crud.py b/tests/test_ipalib/test_crud.py index ecbf0efd5..a7f49f878 100644 --- a/tests/test_ipalib/test_crud.py +++ b/tests/test_ipalib/test_crud.py @@ -52,140 +52,6 @@ class CrudChecker(ClassChecker): return api -class test_Add(CrudChecker): - """ - Test the `ipalib.crud.Add` class. - """ - - _cls = crud.Add - - def test_get_args(self): - """ - Test the `ipalib.crud.Add.get_args` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.args) == ['uid'] - assert api.Method.user_verb.args.uid.required is True - api = self.get_api(args=('extra?',)) - assert list(api.Method.user_verb.args) == ['uid', 'extra'] - assert api.Method.user_verb.args.uid.required is True - assert api.Method.user_verb.args.extra.required is False - - def test_get_options(self): - """ - Test the `ipalib.crud.Add.get_options` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.options) == \ - ['givenname', 'sn', 'initials'] - for param in api.Method.user_verb.options(): - assert param.required is True - api = self.get_api(options=('extra?',)) - assert list(api.Method.user_verb.options) == \ - ['givenname', 'sn', 'initials', 'extra'] - assert api.Method.user_verb.options.extra.required is False - - -class test_Get(CrudChecker): - """ - Test the `ipalib.crud.Get` class. - """ - - _cls = crud.Get - - def test_get_args(self): - """ - Test the `ipalib.crud.Get.get_args` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.args) == ['uid'] - assert api.Method.user_verb.args.uid.required is True - - def test_get_options(self): - """ - Test the `ipalib.crud.Get.get_options` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.options) == [] - assert len(api.Method.user_verb.options) == 0 - - -class test_Del(CrudChecker): - """ - Test the `ipalib.crud.Del` class. - """ - - _cls = crud.Del - - def test_get_args(self): - """ - Test the `ipalib.crud.Del.get_args` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.args) == ['uid'] - assert api.Method.user_verb.args.uid.required is True - - def test_get_options(self): - """ - Test the `ipalib.crud.Del.get_options` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.options) == [] - assert len(api.Method.user_verb.options) == 0 - - -class test_Mod(CrudChecker): - """ - Test the `ipalib.crud.Mod` class. - """ - - _cls = crud.Mod - - def test_get_args(self): - """ - Test the `ipalib.crud.Mod.get_args` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.args) == ['uid'] - assert api.Method.user_verb.args.uid.required is True - - def test_get_options(self): - """ - Test the `ipalib.crud.Mod.get_options` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.options) == \ - ['givenname', 'sn', 'initials'] - for param in api.Method.user_verb.options(): - assert param.required is False - - -class test_Find(CrudChecker): - """ - Test the `ipalib.crud.Find` class. - """ - - _cls = crud.Find - - def test_get_args(self): - """ - Test the `ipalib.crud.Find.get_args` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.args) == ['uid'] - assert api.Method.user_verb.args.uid.required is True - - def test_get_options(self): - """ - Test the `ipalib.crud.Find.get_options` method. - """ - api = self.get_api() - assert list(api.Method.user_verb.options) == \ - ['givenname', 'sn', 'initials'] - for param in api.Method.user_verb.options(): - assert param.required is False - - class test_CrudBackend(ClassChecker): """ Test the `ipalib.crud.CrudBackend` class. diff --git a/tests/test_ipalib/test_frontend.py b/tests/test_ipalib/test_frontend.py index 385219d04..53843cee8 100644 --- a/tests/test_ipalib/test_frontend.py +++ b/tests/test_ipalib/test_frontend.py @@ -703,7 +703,6 @@ class test_Object(ClassChecker): o = example1() o.set_api(api) assert o.primary_key is None - assert o.params_minus_pk is None # Test with 1 primary key: class example2(self.cls): diff --git a/tests/test_ipalib/test_parameters.py b/tests/test_ipalib/test_parameters.py index db9c01efc..d651b2366 100644 --- a/tests/test_ipalib/test_parameters.py +++ b/tests/test_ipalib/test_parameters.py @@ -29,6 +29,7 @@ from tests.util import dummy_ugettext, assert_equal from tests.data import binary_bytes, utf8_bytes, unicode_str from ipalib import parameters, request, errors, config from ipalib.constants import TYPE_ERROR, CALLABLE_ERROR, NULLS +from ipalib.errors import ValidationError class test_DefaultFrom(ClassChecker): @@ -445,11 +446,11 @@ class test_Param(ClassChecker): assert str(e) == 'value: empty tuple must be converted to None' # Test with wrong (scalar) type: - e = raises(TypeError, o.validate, (None, None, 42, None)) - assert str(e) == TYPE_ERROR % ('value[2]', NoneType, 42, int) + e = raises(ValidationError, o.validate, (None, None, 42, None)) + assert str(e) == 'invalid %s' % (TYPE_ERROR % ('\'my_param\'', NoneType, 42, int)) o = self.cls('my_param') - e = raises(TypeError, o.validate, 'Hello') - assert str(e) == TYPE_ERROR % ('value', NoneType, 'Hello', str) + e = raises(ValidationError, o.validate, 'Hello') + assert str(e) == 'invalid %s' % (TYPE_ERROR % ('\'my_param\'', NoneType, 'Hello', str)) class Example(self.cls): type = int @@ -511,10 +512,10 @@ class test_Param(ClassChecker): o = MyParam('my_param', okay) # Test that TypeError is appropriately raised: - e = raises(TypeError, o._validate_scalar, 0) - assert str(e) == TYPE_ERROR % ('value', bool, 0, int) - e = raises(TypeError, o._validate_scalar, 'Hi', index=4) - assert str(e) == TYPE_ERROR % ('value[4]', bool, 'Hi', str) + e = raises(ValidationError, o._validate_scalar, 0) + assert str(e) == 'invalid %s' % (TYPE_ERROR % ('\'my_param\'', bool, 0, int)) + e = raises(ValidationError, o._validate_scalar, 'Hi', index=4) + assert str(e) == 'invalid %s' % (TYPE_ERROR % ('\'my_param\'', bool, 'Hi', str)) e = raises(TypeError, o._validate_scalar, True, index=3.0) assert str(e) == TYPE_ERROR % ('index', int, 3.0, float) |