summaryrefslogtreecommitdiffstats
path: root/ipatests/test_xmlrpc
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2016-09-26 18:22:22 +0200
committerMartin Basti <mbasti@redhat.com>2016-09-27 13:35:58 +0200
commit9d83be3647547cfca4e129cfeb63771213232cf7 (patch)
tree0899bfbc662355dd8d1318b5e6d4909c5aaa993c /ipatests/test_xmlrpc
parent0f88f8fe889ae4801fc8d5ece1ad51c5246718ac (diff)
downloadfreeipa-9d83be3647547cfca4e129cfeb63771213232cf7.tar.gz
freeipa-9d83be3647547cfca4e129cfeb63771213232cf7.tar.xz
freeipa-9d83be3647547cfca4e129cfeb63771213232cf7.zip
Remove unused variables in tests
This commit removes or marks unused variables as "expected to be unused" by using '_' prefix. Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com> Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
Diffstat (limited to 'ipatests/test_xmlrpc')
-rw-r--r--ipatests/test_xmlrpc/test_add_remove_cert_cmd.py4
-rw-r--r--ipatests/test_xmlrpc/test_automount_plugin.py6
-rw-r--r--ipatests/test_xmlrpc/test_baseldap_plugin.py9
-rw-r--r--ipatests/test_xmlrpc/test_cert_plugin.py10
-rw-r--r--ipatests/test_xmlrpc/test_hbac_plugin.py6
-rw-r--r--ipatests/test_xmlrpc/test_hbactest_plugin.py8
-rw-r--r--ipatests/test_xmlrpc/test_host_plugin.py19
-rw-r--r--ipatests/test_xmlrpc/test_permission_plugin.py10
-rw-r--r--ipatests/test_xmlrpc/test_pwpolicy_plugin.py3
-rw-r--r--ipatests/test_xmlrpc/testcert.py4
-rw-r--r--ipatests/test_xmlrpc/tracker/automember_plugin.py8
-rw-r--r--ipatests/test_xmlrpc/tracker/group_plugin.py8
-rw-r--r--ipatests/test_xmlrpc/tracker/hostgroup_plugin.py8
-rw-r--r--ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py4
-rw-r--r--ipatests/test_xmlrpc/tracker/user_plugin.py2
15 files changed, 54 insertions, 55 deletions
diff --git a/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py b/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py
index 014d088c6..edc97f07b 100644
--- a/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py
+++ b/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py
@@ -90,13 +90,13 @@ class CertManipCmdTestBase(XMLRPC_test):
# list of certificates to add to entry
cls.certs = [
get_testcert(DN(('CN', cls.entity_subject)), cls.entity_principal)
- for i in range(3)
+ for _i in range(3)
]
# list of certificates for testing of removal of non-existent certs
cls.nonexistent_certs = [
get_testcert(DN(('CN', cls.entity_subject)), cls.entity_principal)
- for j in range(2)
+ for _j in range(2)
]
# cert subset to remove from entry
diff --git a/ipatests/test_xmlrpc/test_automount_plugin.py b/ipatests/test_xmlrpc/test_automount_plugin.py
index 9379b53ac..e3ad8b49d 100644
--- a/ipatests/test_xmlrpc/test_automount_plugin.py
+++ b/ipatests/test_xmlrpc/test_automount_plugin.py
@@ -184,7 +184,8 @@ class test_automount(AutomountTest):
"""
Test adding a duplicate key using `xmlrpc.automountkey_add` method.
"""
- res = api.Command['automountkey_add'](self.locname, self.mapname, **self.key_kw)
+ api.Command['automountkey_add'](
+ self.locname, self.mapname, **self.key_kw)
def test_5_automountmap_show(self):
"""
@@ -368,7 +369,8 @@ class test_automount_direct(AutomountTest):
"""
Test adding a duplicate direct map.
"""
- res = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.direct_kw)['result']
+ api.Command['automountmap_add_indirect'](
+ self.locname, self.mapname, **self.direct_kw)
def test_2a_automountmap_tofiles(self):
"""Test the `automountmap_tofiles` command"""
diff --git a/ipatests/test_xmlrpc/test_baseldap_plugin.py b/ipatests/test_xmlrpc/test_baseldap_plugin.py
index 50a9f1eb6..2ea28795e 100644
--- a/ipatests/test_xmlrpc/test_baseldap_plugin.py
+++ b/ipatests/test_xmlrpc/test_baseldap_plugin.py
@@ -53,7 +53,8 @@ def test_exc_wrapper():
# Test with one callback first
@test_callback.register_exc_callback
- def handle_exception(self, keys, options, e, call_func, *args, **kwargs):
+ def handle_exception( # pylint: disable=unused-variable
+ self, keys, options, e, call_func, *args, **kwargs):
assert args == (1, 2)
assert kwargs == dict(a=1, b=2)
handled_exceptions.append(type(e))
@@ -150,7 +151,8 @@ def test_exc_callback_registration():
pass
@callbacktest_subclass.register_exc_callback
- def exc_callback(self, keys, options, exc, call_func, *args, **kwargs):
+ def exc_callback( # pylint: disable=unused-variable
+ self, keys, options, exc, call_func, *args, **kwargs):
"""Subclass's private exception callback"""
messages.append('Subclass registered callback')
raise exc
@@ -163,7 +165,8 @@ def test_exc_callback_registration():
@callbacktest_base.register_exc_callback
- def exc_callback_2(self, keys, options, exc, call_func, *args, **kwargs):
+ def exc_callback_2( # pylint: disable=unused-variable
+ self, keys, options, exc, call_func, *args, **kwargs):
"""Callback on super class; doesn't affect the subclass"""
messages.append('Superclass registered callback')
raise exc
diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py
index ab09d0aa4..f07bb1791 100644
--- a/ipatests/test_xmlrpc/test_cert_plugin.py
+++ b/ipatests/test_xmlrpc/test_cert_plugin.py
@@ -141,11 +141,11 @@ class test_cert(XMLRPC_test):
This should fail because the service principal doesn't exist
"""
# First create the host that will use this policy
- res = api.Command['host_add'](self.host_fqdn, force= True)['result']
+ assert 'result' in api.Command['host_add'](self.host_fqdn, force=True)
csr = unicode(self.generateCSR(str(self.subject)))
with assert_raises(errors.NotFound):
- res = api.Command['cert_request'](csr, principal=self.service_princ)
+ api.Command['cert_request'](csr, principal=self.service_princ)
def test_0002_cert_add(self):
"""
@@ -267,7 +267,7 @@ class test_cert_find(XMLRPC_test):
"""
Search for the OCSP certificate.
"""
- res = api.Command['cert_find'](subject=u'OCSP Subsystem')
+ api.Command['cert_find'](subject=u'OCSP Subsystem')
def test_0004_find_this_host(self):
"""
@@ -458,7 +458,7 @@ class test_cert_find(XMLRPC_test):
"""
Search with a negative sizelimit
"""
- res = api.Command['cert_find'](sizelimit=-100)
+ api.Command['cert_find'](sizelimit=-100)
def test_0029_search_for_notfound(self):
"""
@@ -479,4 +479,4 @@ class test_cert_find(XMLRPC_test):
"""
Search using invalid date format
"""
- res = api.Command['cert_find'](issuedon_from=u'xyz')
+ api.Command['cert_find'](issuedon_from=u'xyz')
diff --git a/ipatests/test_xmlrpc/test_hbac_plugin.py b/ipatests/test_xmlrpc/test_hbac_plugin.py
index 55b038754..75c15c5ab 100644
--- a/ipatests/test_xmlrpc/test_hbac_plugin.py
+++ b/ipatests/test_xmlrpc/test_hbac_plugin.py
@@ -268,7 +268,7 @@ class test_hbac(XMLRPC_test):
"""
Test deprecated command hbacrule_add_sourcehost.
"""
- ret = api.Command['hbacrule_add_sourcehost'](
+ api.Command['hbacrule_add_sourcehost'](
self.rule_name, host=self.test_host, hostgroup=self.test_hostgroup
)
@@ -307,7 +307,7 @@ class test_hbac(XMLRPC_test):
"""
Test deprecated command hbacrule_remove_sourcehost.
"""
- ret = api.Command['hbacrule_remove_sourcehost'](
+ api.Command['hbacrule_remove_sourcehost'](
self.rule_name, host=self.test_host, hostgroup=self.test_hostgroup
)
@@ -316,7 +316,7 @@ class test_hbac(XMLRPC_test):
"""
Test adding the same external host using `xmlrpc.hbacrule_add_host`.
"""
- ret = api.Command['hbacrule_mod'](
+ api.Command['hbacrule_mod'](
self.rule_name, setattr=self.test_invalid_sourcehost
)
diff --git a/ipatests/test_xmlrpc/test_hbactest_plugin.py b/ipatests/test_xmlrpc/test_hbactest_plugin.py
index bad59f4c8..12ecfc338 100644
--- a/ipatests/test_xmlrpc/test_hbactest_plugin.py
+++ b/ipatests/test_xmlrpc/test_hbactest_plugin.py
@@ -91,20 +91,20 @@ class test_hbactest(XMLRPC_test):
self.rule_names[i], accessruletype=self.rule_type, description=self.rule_descs[i],
)
- ret = api.Command['hbacrule_add_user'](
+ api.Command['hbacrule_add_user'](
self.rule_names[i], user=self.test_user, group=self.test_group
)
- ret = api.Command['hbacrule_add_host'](
+ api.Command['hbacrule_add_host'](
self.rule_names[i], host=self.test_host, hostgroup=self.test_hostgroup
)
- ret = api.Command['hbacrule_add_service'](
+ api.Command['hbacrule_add_service'](
self.rule_names[i], hbacsvc=self.test_service
)
if i & 1:
- ret = api.Command['hbacrule_disable'](self.rule_names[i])
+ api.Command['hbacrule_disable'](self.rule_names[i])
def test_a_hbactest_check_rules_detail(self):
"""
diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py
index 279186b70..b36c6b812 100644
--- a/ipatests/test_xmlrpc/test_host_plugin.py
+++ b/ipatests/test_xmlrpc/test_host_plugin.py
@@ -619,9 +619,9 @@ class TestHostDNS(XMLRPC_test):
try:
ipv6only_host.create(force=False)
finally:
- command = ipv6only_host.run_command('dnsrecord_del', dnszone,
- ipv6only_host.shortname,
- aaaarecord=aaaarec)
+ ipv6only_host.run_command(
+ 'dnsrecord_del', dnszone, ipv6only_host.shortname,
+ aaaarecord=aaaarec)
def test_add_ipv4only_host(self, dns_setup, ipv4only_host):
ipv4only_host.run_command('dnsrecord_add', dnszone,
@@ -629,9 +629,9 @@ class TestHostDNS(XMLRPC_test):
try:
ipv4only_host.create(force=False)
finally:
- command = ipv4only_host.run_command('dnsrecord_del', dnszone,
- ipv4only_host.shortname,
- arecord=arec)
+ ipv4only_host.run_command(
+ 'dnsrecord_del', dnszone, ipv4only_host.shortname,
+ arecord=arec)
def test_add_ipv46both_host(self, dns_setup, ipv46both_host):
ipv46both_host.run_command('dnsrecord_add', dnszone,
@@ -640,10 +640,9 @@ class TestHostDNS(XMLRPC_test):
try:
ipv46both_host.create(force=False)
finally:
- command = ipv46both_host.run_command('dnsrecord_del', dnszone,
- ipv46both_host.shortname,
- arecord=arec2,
- aaaarecord=aaaarec2)
+ ipv46both_host.run_command(
+ 'dnsrecord_del', dnszone, ipv46both_host.shortname,
+ arecord=arec2, aaaarecord=aaaarec2)
def test_add_ipv4_host_from_ip(self, dns_setup, ipv4_fromip_host):
ipv4_fromip_host.ensure_missing()
diff --git a/ipatests/test_xmlrpc/test_permission_plugin.py b/ipatests/test_xmlrpc/test_permission_plugin.py
index fe4a5b959..6336df7c1 100644
--- a/ipatests/test_xmlrpc/test_permission_plugin.py
+++ b/ipatests/test_xmlrpc/test_permission_plugin.py
@@ -138,7 +138,7 @@ def lineinfo(level):
# Including this info in the test name makes it possible
# to locate failing tests.
frame = inspect.currentframe()
- for i in range(level):
+ for _i in range(level):
frame = frame.f_back
lineno = frame.f_lineno
filename = os.path.basename(frame.f_code.co_filename)
@@ -3455,9 +3455,8 @@ class test_managed_permissions(Declarative):
ldap = ldap2(api)
ldap.connect()
- result = api.Command.permission_add(permission1, type=u'user',
- ipapermright=u'write',
- attrs=[u'cn'])
+ api.Command.permission_add(
+ permission1, type=u'user', ipapermright=u'write', attrs=[u'cn'])
# TODO: This hack relies on the permission internals.
# Change as necessary.
@@ -3468,8 +3467,7 @@ class test_managed_permissions(Declarative):
ldap.update_entry(entry)
# Update the ACI via the API
- result = api.Command.permission_mod(permission1,
- attrs=[u'l', u'o', u'cn'])
+ api.Command.permission_mod(permission1, attrs=[u'l', u'o', u'cn'])
# Set the permission type to MANAGED
entry = ldap.get_entry(permission1_dn)
diff --git a/ipatests/test_xmlrpc/test_pwpolicy_plugin.py b/ipatests/test_xmlrpc/test_pwpolicy_plugin.py
index 381674608..239ce5b7d 100644
--- a/ipatests/test_xmlrpc/test_pwpolicy_plugin.py
+++ b/ipatests/test_xmlrpc/test_pwpolicy_plugin.py
@@ -163,7 +163,8 @@ class test_pwpolicy(XMLRPC_test):
Test adding password policy to a managed group.
"""
try:
- entry = api.Command['pwpolicy_add'](self.user, krbminpwdlife=50, cospriority=2)['result']
+ api.Command['pwpolicy_add'](
+ self.user, krbminpwdlife=50, cospriority=2)
except errors.ManagedPolicyError:
pass
else:
diff --git a/ipatests/test_xmlrpc/testcert.py b/ipatests/test_xmlrpc/testcert.py
index b7abcdcec..def820f16 100644
--- a/ipatests/test_xmlrpc/testcert.py
+++ b/ipatests/test_xmlrpc/testcert.py
@@ -93,10 +93,6 @@ def makecert(reqdir, subject, principal):
# Generate NSS cert database to store the private key for our CSR
run_certutil(reqdir, ["-N", "-f", pwname])
- res = api.Command['config_show']()
- subject_base = res['result']['ipacertificatesubjectbase'][0]
-
- cert = None
csr = unicode(generate_csr(reqdir, pwname, str(subject)))
res = api.Command['cert_request'](csr, principal=principal, add=True)
diff --git a/ipatests/test_xmlrpc/tracker/automember_plugin.py b/ipatests/test_xmlrpc/tracker/automember_plugin.py
index 61f87c365..151668945 100644
--- a/ipatests/test_xmlrpc/tracker/automember_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/automember_plugin.py
@@ -110,7 +110,7 @@ class AutomemberTracker(Tracker):
try:
self.attrs[u'group'] =\
self.attrs[u'group'] + [options[u'group']]
- except KeyError as ex:
+ except KeyError:
self.attrs[u'group'] = [options[u'group']]
# search for hosts in the target automember and
# add them as memberindirect hosts
@@ -118,7 +118,7 @@ class AutomemberTracker(Tracker):
try:
self.attrs[u'hostgroup'] =\
self.attrs[u'hostgroup'] + [options[u'hostgroup']]
- except KeyError as ex:
+ except KeyError:
self.attrs[u'hostgroup'] = [options[u'hostgroup']]
command = self.make_add_member_command(options)
@@ -135,12 +135,12 @@ class AutomemberTracker(Tracker):
try:
if not self.attrs[u'member_host']:
del self.attrs[u'member_host']
- except KeyError as ex:
+ except KeyError:
pass
try:
if not self.attrs[u'member_automember']:
del self.attrs[u'member_automember']
- except KeyError as ex:
+ except KeyError:
pass
command = self.make_remove_member_command(options)
diff --git a/ipatests/test_xmlrpc/tracker/group_plugin.py b/ipatests/test_xmlrpc/tracker/group_plugin.py
index 94a4cdc8c..5d039d441 100644
--- a/ipatests/test_xmlrpc/tracker/group_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/group_plugin.py
@@ -117,13 +117,13 @@ class GroupTracker(Tracker):
try:
self.attrs[u'member_user'] =\
self.attrs[u'member_user'] + [options[u'user']]
- except KeyError as ex:
+ except KeyError:
self.attrs[u'member_user'] = [options[u'user']]
elif u'group' in options:
try:
self.attrs[u'member_group'] =\
self.attrs[u'member_group'] + [options[u'group']]
- except KeyError as ex:
+ except KeyError:
self.attrs[u'member_group'] = [options[u'group']]
command = self.make_add_member_command(options)
@@ -140,12 +140,12 @@ class GroupTracker(Tracker):
try:
if not self.attrs[u'member_user']:
del self.attrs[u'member_user']
- except KeyError as ex:
+ except KeyError:
pass
try:
if not self.attrs[u'member_group']:
del self.attrs[u'member_group']
- except KeyError as ex:
+ except KeyError:
pass
command = self.make_remove_member_command(options)
diff --git a/ipatests/test_xmlrpc/tracker/hostgroup_plugin.py b/ipatests/test_xmlrpc/tracker/hostgroup_plugin.py
index 8b63c90b0..080d0120a 100644
--- a/ipatests/test_xmlrpc/tracker/hostgroup_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/hostgroup_plugin.py
@@ -91,7 +91,7 @@ class HostGroupTracker(Tracker):
try:
self.attrs[u'member_host'] =\
self.attrs[u'member_host'] + [options[u'host']]
- except KeyError as ex:
+ except KeyError:
self.attrs[u'member_host'] = [options[u'host']]
# search for hosts in the target hostgroup and
# add them as memberindirect hosts
@@ -99,7 +99,7 @@ class HostGroupTracker(Tracker):
try:
self.attrs[u'member_hostgroup'] =\
self.attrs[u'member_hostgroup'] + [options[u'hostgroup']]
- except KeyError as ex:
+ except KeyError:
self.attrs[u'member_hostgroup'] = [options[u'hostgroup']]
command = self.make_add_member_command(options)
@@ -116,12 +116,12 @@ class HostGroupTracker(Tracker):
try:
if not self.attrs[u'member_host']:
del self.attrs[u'member_host']
- except KeyError as ex:
+ except KeyError:
pass
try:
if not self.attrs[u'member_hostgroup']:
del self.attrs[u'member_hostgroup']
- except KeyError as ex:
+ except KeyError:
pass
command = self.make_remove_member_command(options)
diff --git a/ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py b/ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py
index f7440540c..a571974c5 100644
--- a/ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/sudocmdgroup_plugin.py
@@ -88,7 +88,7 @@ class SudoCmdGroupTracker(Tracker):
try:
self.attrs[u'member_sudocmd'] =\
self.attrs[u'member_sudocmd'] + [options[u'sudocmd']]
- except KeyError as ex:
+ except KeyError:
self.attrs[u'member_sudocmd'] = [options[u'sudocmd']]
command = self.make_add_member_command(options)
@@ -102,7 +102,7 @@ class SudoCmdGroupTracker(Tracker):
try:
if not self.attrs[u'member_sudocmd']:
del self.attrs[u'member_sudocmd']
- except KeyError as ex:
+ except KeyError:
pass
command = self.make_remove_member_command(options)
diff --git a/ipatests/test_xmlrpc/tracker/user_plugin.py b/ipatests/test_xmlrpc/tracker/user_plugin.py
index 6bc0ce19c..4485fd9b4 100644
--- a/ipatests/test_xmlrpc/tracker/user_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/user_plugin.py
@@ -165,7 +165,7 @@ class UserTracker(KerberosAliasMixin, Tracker):
(self.kwargs[key].split('@'))[0].lower(),
(self.kwargs[key].split('@'))[1]
)]
- except IndexError as ex:
+ except IndexError:
# we can provide just principal part
self.attrs[key] = [u'%s@%s' % (
(self.kwargs[key].lower(),