Add utility functions for plugin unit testing.

This commit is contained in:
Pavel Zuna
2009-06-24 15:10:05 +02:00
committed by Rob Crittenden
parent 12ee586392
commit 57b55d8e2f

View File

@@ -27,6 +27,17 @@ import nose
from ipalib import api, request from ipalib import api, request
from ipalib import errors from ipalib import errors
def assert_attr_equal(entry_attrs, attr, value):
assert value in entry_attrs.get(attr, [])
def assert_is_member(entry_attrs, value, member_attr='member'):
for m in entry_attrs[member_attr]:
if m.startswith(value):
return
assert False
# Initialize the API. We do this here so that one can run the tests # Initialize the API. We do this here so that one can run the tests
# individually instead of at the top-level. If API.bootstrap() # individually instead of at the top-level. If API.bootstrap()
# has already been called we continue gracefully. Other errors will be # has already been called we continue gracefully. Other errors will be
@@ -52,3 +63,4 @@ class XMLRPC_test(object):
nose tear-down fixture. nose tear-down fixture.
""" """
request.destroy_context() request.destroy_context()