From 690e5c955697fad2be8742e5a581f1e2a39d17b0 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 27 Oct 2015 11:45:56 -0300 Subject: Pylint fixes and ignores for incoming oo-install code. --- utils/test/cli_installer_tests.py | 26 +++++++++++++++++--------- utils/test/oo_config_tests.py | 12 ++++++++---- 2 files changed, 25 insertions(+), 13 deletions(-) (limited to 'utils/test') diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index 78e3ab3bf..076fe5dc9 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -1,4 +1,7 @@ -import sys +# TODO: Temporarily disabled due to importing old code into openshift-ansible +# repo. We will work on these over time. +# pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name + import copy import os import ConfigParser @@ -7,7 +10,7 @@ import yaml import ooinstall.cli_installer as cli from click.testing import CliRunner -from oo_config_tests import OOInstallFixture +from test.oo_config_tests import OOInstallFixture from mock import patch @@ -77,14 +80,14 @@ class OOCliFixture(OOInstallFixture): def assert_result(self, result, exit_code): if result.exception is not None or result.exit_code != exit_code: - print("Unexpected result from CLI execution") - print("Exit code: %s" % result.exit_code) - print("Exception: %s" % result.exception) + print "Unexpected result from CLI execution" + print "Exit code: %s" % result.exit_code + print "Exception: %s" % result.exception print result.exc_info import traceback traceback.print_exception(*result.exc_info) - print("Output:\n%s" % result.output) - self.assertTrue("Exception during CLI execution", False) + print "Output:\n%s" % result.output + self.fail("Exception during CLI execution") def _read_yaml(self, config_file_path): f = open(config_file_path, 'r') @@ -261,6 +264,9 @@ class UnattendedCliTests(OOCliFixture): self._ansible_config_test(load_facts_mock, run_ansible_mock, config, None, ansible_config) + #pylint: disable=too-many-arguments + # This method allows for drastically simpler tests to write, and the args + # are all useful. def _ansible_config_test(self, load_facts_mock, run_ansible_mock, installer_config, ansible_config_cli=None, expected_result=None): """ @@ -287,7 +293,7 @@ class UnattendedCliTests(OOCliFixture): self.assertFalse('ANSIBLE_CONFIG' in facts_env_vars) # Test the env vars for main playbook: - playbook, inventory, env_vars = run_ansible_mock.call_args[0] + env_vars = run_ansible_mock.call_args[0][2] if expected_result: self.assertEquals(expected_result, env_vars['ANSIBLE_CONFIG']) else: @@ -302,7 +308,9 @@ class AttendedCliTests(OOCliFixture): self.config_file = os.path.join(self.work_dir, 'config.yml') self.cli_args.extend(["-c", self.config_file]) - def _build_input(self, ssh_user=None, hosts=None, variant_num=None, add_nodes=None, confirm_facts=None): + #pylint: disable=too-many-arguments + def _build_input(self, ssh_user=None, hosts=None, variant_num=None, + add_nodes=None, confirm_facts=None): """ Builds a CLI input string with newline characters to simulate the full run. diff --git a/utils/test/oo_config_tests.py b/utils/test/oo_config_tests.py index 8459b7c39..01af33fd9 100644 --- a/utils/test/oo_config_tests.py +++ b/utils/test/oo_config_tests.py @@ -1,3 +1,7 @@ +# TODO: Temporarily disabled due to importing old code into openshift-ansible +# repo. We will work on these over time. +# pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name + import os import unittest import tempfile @@ -64,9 +68,9 @@ class OOInstallFixture(unittest.TestCase): up in teardown. Returns full path to the file. """ - f = open(path, 'w') - f.write(config_str) - f.close() + cfg_file = open(path, 'w') + cfg_file.write(config_str) + cfg_file.close() return path @@ -88,7 +92,7 @@ class OOConfigTests(OOInstallFixture): self.assertEquals('openshift-enterprise', ooconfig.settings['variant']) - def test_load_complete_validated_facts(self): + def test_load_complete_facts(self): cfg_path = self.write_config(os.path.join(self.work_dir, 'ooinstall.conf'), SAMPLE_CONFIG) ooconfig = OOConfig(cfg_path) -- cgit v1.2.3