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
2015-10-14 08:59:08 +02:00
committed by Martin Basti
parent 6a401fbf31
commit af1f6721e1
2 changed files with 15 additions and 1 deletions

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,

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.