fix class teardown in user plugin tests

https://fedorahosted.org/freeipa/ticket/5368

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Martin Babinsky authored and Martin Basti committed 2015-10-22 13:15:43 +02:00
1 parent 6a401fbf31
commit af1f6721e1
2 files changed
+15 -1

No files matched your search

+5
View File
@@ -1619,6 +1619,11 @@ class test_denied_bind_with_expired_principal(XMLRPC_test):
cls.connection = ldap.initialize('ldap://{host}'
.format(host=api.env.host))
@classmethod
def teardown_class(cls):
cls.failsafe_del(api.Object.user, user1)
super(test_denied_bind_with_expired_principal, cls).teardown_class()
def test_1_bind_as_test_user(self):
self.failsafe_add(
api.Object.user,
+10 -1
View File
@@ -195,11 +195,20 @@ class XMLRPC_test(object):
:param pk: The primary key of the entry to be created
:param options: Kwargs to be passed to obj.add()
"""
self.failsafe_del(obj, pk)
return obj.methods['add'](pk, **options)
@classmethod
def failsafe_del(cls, obj, pk):
"""
Delete an entry if it exists
:param obj: An Object like api.Object.user
:param pk: The primary key of the entry to be deleted
"""
try:
obj.methods['del'](pk)
except errors.NotFound:
pass
return obj.methods['add'](pk, **options)
IGNORE = """Command %r is missing attribute %r in output entry.