From 48d666979695ddcf1e0856588e394833e3995f66 Mon Sep 17 00:00:00 2001 From: Pavel Zuna Date: Thu, 2 Jul 2009 16:56:51 +0200 Subject: Fix unit tests to handle new group-{add, del}-member semantics. --- tests/test_xmlrpc/test_group_plugin.py | 10 ++++--- tests/test_xmlrpc/test_hostgroup_plugin.py | 4 +-- tests/test_xmlrpc/test_netgroup_plugin.py | 42 ++++++++++++++++++------------ tests/test_xmlrpc/test_rolegroup_plugin.py | 4 +-- tests/test_xmlrpc/test_taskgroup_plugin.py | 4 +-- 5 files changed, 37 insertions(+), 27 deletions(-) (limited to 'tests') diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py index d509c1045..d1024fcac 100644 --- a/tests/test_xmlrpc/test_group_plugin.py +++ b/tests/test_xmlrpc/test_group_plugin.py @@ -71,7 +71,7 @@ class test_group(XMLRPC_test): """ kw = {} kw['groups'] = self.cn2 - (total, res) = api.Command['group_add_member'](self.cn, **kw) + (total, failed, res) = api.Command['group_add_member'](self.cn, **kw) assert total == 1 def test_4_group_add_member(self): @@ -80,8 +80,9 @@ class test_group(XMLRPC_test): """ kw = {} kw['groups'] = u'notfound' - (total, res) = api.Command['group_add_member'](self.cn, **kw) + (total, failed, res) = api.Command['group_add_member'](self.cn, **kw) assert total == 0 + assert 'notfound' in failed def test_5_group_show(self): """ @@ -141,7 +142,7 @@ class test_group(XMLRPC_test): """ kw = {} kw['groups'] = self.cn2 - (total, res) = api.Command['group_del_member'](self.cn, **kw) + (total, failed, res) = api.Command['group_del_member'](self.cn, **kw) assert res assert total == 1 @@ -152,8 +153,9 @@ class test_group(XMLRPC_test): kw = {} kw['groups'] = u'notfound' # an error isn't thrown, the list of failed members is returned - (total, res) = api.Command['group_del_member'](self.cn, **kw) + (total, failed, res) = api.Command['group_del_member'](self.cn, **kw) assert total == 0 + assert 'notfound' in failed def test_b_group_del(self): """ diff --git a/tests/test_xmlrpc/test_hostgroup_plugin.py b/tests/test_xmlrpc/test_hostgroup_plugin.py index bea3b3d6d..6e26e0992 100644 --- a/tests/test_xmlrpc/test_hostgroup_plugin.py +++ b/tests/test_xmlrpc/test_hostgroup_plugin.py @@ -64,7 +64,7 @@ class test_hostgroup(XMLRPC_test): """ kw = {} kw['hosts'] = self.host_fqdn - (total, res) = api.Command['hostgroup_add_member'](self.cn, **kw) + (total, failed, res) = api.Command['hostgroup_add_member'](self.cn, **kw) assert res[1].get('member', []) != [] def test_4_hostgroup_show(self): @@ -107,7 +107,7 @@ class test_hostgroup(XMLRPC_test): """ kw = {} kw['hosts'] = self.host_fqdn - (total, res) = api.Command['hostgroup_del_member'](self.cn, **kw) + (total, failed, res) = api.Command['hostgroup_del_member'](self.cn, **kw) assert res assert res[1].get('member', []) == [] diff --git a/tests/test_xmlrpc/test_netgroup_plugin.py b/tests/test_xmlrpc/test_netgroup_plugin.py index ff057306d..b447e0174 100644 --- a/tests/test_xmlrpc/test_netgroup_plugin.py +++ b/tests/test_xmlrpc/test_netgroup_plugin.py @@ -97,25 +97,25 @@ class test_netgroup(XMLRPC_test): """ kw = {} kw['hosts'] = self.host_fqdn - (total, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 1 assert_is_member(res[1], 'fqdn=%s' % self.host_fqdn) kw = {} kw['hostgroups'] = self.hg_cn - (total, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 1 assert_is_member(res[1], 'cn=%s' % self.hg_cn) kw = {} kw['users'] = self.user_uid - (total, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 1 assert_is_member(res[1], 'uid=%s' % self.user_uid) kw = {} kw['groups'] = self.group_cn - (total, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 1 assert_is_member(res[1], 'cn=%s' % self.group_cn) @@ -125,23 +125,27 @@ class test_netgroup(XMLRPC_test): """ kw = {} kw['hosts'] = self.host_fqdn - (total, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 0 + assert self.host_fqdn in failed kw = {} kw['hostgroups'] = self.hg_cn - (total, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 0 + assert self.hg_cn in failed kw = {} kw['users'] = self.user_uid - res = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 0 + assert self.user_uid in failed kw = {} kw['groups'] = self.group_cn - res = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 0 + assert self.group_cn in failed def test_5_netgroup_add_member(self): """ @@ -149,7 +153,7 @@ class test_netgroup(XMLRPC_test): """ kw = {} kw['hosts'] = u'nosuchhost' - (total, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_add_member'](self.ng_cn, **kw) assert total == 1 (dn, res) = api.Command['netgroup_show'](self.ng_cn) @@ -200,22 +204,22 @@ class test_netgroup(XMLRPC_test): """ kw = {} kw['hosts'] = self.host_fqdn - (total, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) assert total == 1 kw = {} kw['hostgroups'] = self.hg_cn - (total, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) assert total == 1 kw = {} kw['users'] = self.user_uid - (total, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) assert total == 1 kw = {} kw['groups'] = self.group_cn - (total, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) assert total == 1 def test_a_netgroup_del_member(self): @@ -224,24 +228,28 @@ class test_netgroup(XMLRPC_test): """ kw = {} kw['hosts'] = self.host_fqdn - (total, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) assert total == 0 + assert self.host_fqdn in failed kw = {} kw['hostgroups'] = self.hg_cn - (total, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) assert total == 0 + assert self.hg_cn in failed kw = {} kw['users'] = self.user_uid (dn, res) = api.Command['netgroup_show'](self.ng_cn, all=True) - (total, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) assert total == 0 + assert self.user_uid in failed kw = {} kw['groups'] = self.group_cn - (total, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) + (total, failed, res) = api.Command['netgroup_del_member'](self.ng_cn, **kw) assert total == 0 + assert self.group_cn in failed def test_b_netgroup_del(self): """ diff --git a/tests/test_xmlrpc/test_rolegroup_plugin.py b/tests/test_xmlrpc/test_rolegroup_plugin.py index 8ca796e6a..9a93a926b 100644 --- a/tests/test_xmlrpc/test_rolegroup_plugin.py +++ b/tests/test_xmlrpc/test_rolegroup_plugin.py @@ -63,7 +63,7 @@ class test_rolegroup(XMLRPC_test): """ kw = {} kw['groups'] = self.rolegroup_cn - (total, res) = api.Command['rolegroup_add_member'](self.cn, **kw) + (total, failed, res) = api.Command['rolegroup_add_member'](self.cn, **kw) assert total == 1 def test_4_rolegroup_show(self): @@ -108,7 +108,7 @@ class test_rolegroup(XMLRPC_test): """ kw = {} kw['groups'] = self.rolegroup_cn - (total, res) = api.Command['rolegroup_del_member'](self.cn, **kw) + (total, failed, res) = api.Command['rolegroup_del_member'](self.cn, **kw) assert total == 1 def test_8_rolegroup_del(self): diff --git a/tests/test_xmlrpc/test_taskgroup_plugin.py b/tests/test_xmlrpc/test_taskgroup_plugin.py index b1e811c76..9cede858c 100644 --- a/tests/test_xmlrpc/test_taskgroup_plugin.py +++ b/tests/test_xmlrpc/test_taskgroup_plugin.py @@ -77,7 +77,7 @@ class test_taskgroup(XMLRPC_test): kw = {} kw['groups'] = self.taskgroup_cn kw['rolegroups'] = self.rolegroup_cn - (total, res) = api.Command['taskgroup_add_member'](self.cn, **kw) + (total, failed, res) = api.Command['taskgroup_add_member'](self.cn, **kw) assert total == 2 def test_5_taskgroup_show(self): @@ -124,7 +124,7 @@ class test_taskgroup(XMLRPC_test): """ kw = {} kw['groups'] = self.taskgroup_cn - (total, res) = api.Command['taskgroup_del_member'](self.cn, **kw) + (total, failed, res) = api.Command['taskgroup_del_member'](self.cn, **kw) assert total == 1 def test_9_taskgroup_del(self): -- cgit