diff options
author | John Dennis <jdennis@redhat.com> | 2011-08-09 21:21:56 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2011-08-16 23:52:41 -0400 |
commit | 9df6a4ed8cfa21e398ccb054e7ef4aaf323bdd70 (patch) | |
tree | 85e549b842aa7c9cbef54f44abdae0f4130ec3d0 /tests/test_xmlrpc/test_sudocmd_plugin.py | |
parent | 97f0671ce9dd1d260fea4e95f6e6e017a1ef1048 (diff) | |
download | freeipa-9df6a4ed8cfa21e398ccb054e7ef4aaf323bdd70.tar.gz freeipa-9df6a4ed8cfa21e398ccb054e7ef4aaf323bdd70.tar.xz freeipa-9df6a4ed8cfa21e398ccb054e7ef4aaf323bdd70.zip |
ticket 1600 - convert unittests to use DN objects
We have a larger goal of replacing all DN creation via string
formatting/concatenation with DN object operations because string
operations are not a safe way to form a DN nor to compare a DN. This
work needs to be broken into smaller chunks for easier review and
testing.
Addressing the unit tests first makes sense because we don't want to
be modifying both the core code and the tests used to verify the core
code simultaneously. If we modify the unittests first with existing
core code and no regressions are found then we can move on to
modifying parts of the core code with the belief the unittests can
validate the changes in the core code. Also by doing the unittests
first we also help to validate the DN objects are working correctly
(although they do have an extensive unittest).
The fundamental changes are:
* replace string substitution & concatenation with DN object
constructor
* when comparing dn's the comparision is done after promotion
to a DN object, then two DN objects are compared
* when a list of string dn's are to be compared a new list is
formed where each string dn is replaced by a DN object
* because the unittest framework accepts a complex data structure of
expected values where dn's are represeted as strings the unittest
needs to express the expected value of a dn as a callable object
(e.g. a lambda expression) which promotes the dn string to a DN
object in order to do the comparision.
Diffstat (limited to 'tests/test_xmlrpc/test_sudocmd_plugin.py')
-rw-r--r-- | tests/test_xmlrpc/test_sudocmd_plugin.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/test_xmlrpc/test_sudocmd_plugin.py b/tests/test_xmlrpc/test_sudocmd_plugin.py index 2a5dcb0af..a19fefc73 100644 --- a/tests/test_xmlrpc/test_sudocmd_plugin.py +++ b/tests/test_xmlrpc/test_sudocmd_plugin.py @@ -24,7 +24,7 @@ Test the `ipalib/plugins/sudocmd.py` module. from ipalib import api, errors from tests.test_xmlrpc.xmlrpc_test import Declarative, fuzzy_uuid from tests.test_xmlrpc import objectclasses - +from ipalib.dn import * sudocmd1 = u'/usr/bin/sudotestcmd1' @@ -69,8 +69,9 @@ class test_sudocmd(Declarative): value=sudocmd1, summary=u'Added sudo command "%s"' % sudocmd1, result=dict( - dn=u'sudocmd=%s,cn=sudocmds,cn=sudo,%s' % (sudocmd1, - api.env.basedn), + dn=lambda x: DN(x) == \ + DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), sudocmd=[sudocmd1], description=[u'Test sudo command 1'], objectclass=objectclasses.sudocmd, @@ -98,8 +99,9 @@ class test_sudocmd(Declarative): value=sudocmd1, summary=None, result=dict( - dn=u'sudocmd=%s,cn=sudocmds,cn=sudo,%s' % (sudocmd1, - api.env.basedn), + dn=lambda x: DN(x) == \ + DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), sudocmd=[sudocmd1], description=[u'Test sudo command 1'], ), @@ -116,8 +118,9 @@ class test_sudocmd(Declarative): summary=u'1 sudo command matched', result=[ dict( - dn=u'sudocmd=%s,cn=sudocmds,cn=sudo,%s' % (sudocmd1, - api.env.basedn), + dn=lambda x: DN(x) == \ + DN(('sudocmd',sudocmd1),('cn','sudocmds'), + ('cn','sudo'),api.env.basedn), sudocmd=[sudocmd1], description=[u'Test sudo command 1'], ), @@ -148,8 +151,9 @@ class test_sudocmd(Declarative): value=sudocmd1, summary=None, result=dict( - dn=u'sudocmd=%s,cn=sudocmds,cn=sudo,%s' % (sudocmd1, - api.env.basedn), + dn=lambda x: DN(x) == \ + DN(('sudocmd',sudocmd1),('cn','sudocmds'),('cn','sudo'), + api.env.basedn), sudocmd=[sudocmd1], description=[u'Updated sudo command 1'], ), |