From c67af323755341b2e841b0ef47361ba666529321 Mon Sep 17 00:00:00 2001 From: Nguyen Hung Phuong Date: Wed, 7 Sep 2016 14:31:54 +0700 Subject: [PATCH] Clean imports in code In some part in the code we import objects. In the Openstack style guidelines they recommend to import only modules. http://docs.openstack.org/developer/hacking/#imports Change-Id: I74d8cdbe6f487aeed375e77dc7671cfcf22512e2 --- doc/source/conf.py | 4 ++-- plugin_test/helpers/contrail_client.py | 14 +++++++------- plugin_test/helpers/openstack.py | 4 ++-- plugin_test/run_tests.py | 4 ++-- plugin_test/tests/test_failover.py | 9 ++++----- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index becf00906..756164bb6 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,4 +1,4 @@ -from distutils.version import LooseVersion +from distutils import version from sphinx import __version__ as sphinx_version mypreamble=ur''' @@ -52,7 +52,7 @@ latex_elements = { 'fontpkg': '\usepackage[T1]{fontenc}' } -if LooseVersion(sphinx_version) >= LooseVersion('1.3.1'): +if version.LooseVersion(sphinx_version) >= version.LooseVersion('1.3.1'): html_theme = "sphinx_rtd_theme" html_add_permalinks = "" diff --git a/plugin_test/helpers/contrail_client.py b/plugin_test/helpers/contrail_client.py index 6e4808efd..bb501a034 100644 --- a/plugin_test/helpers/contrail_client.py +++ b/plugin_test/helpers/contrail_client.py @@ -13,8 +13,8 @@ License for the specific language governing permissions and limitations under the License. """ from fuelweb_test import logwrap -from keystoneauth1.identity.v2 import Password # TODO(otsvigun) v3 -from keystoneauth1.session import Session +from keystoneauth1.identity import v2 # TODO(otsvigun) v3 +from keystoneauth1 import session from fuelweb_test.settings import KEYSTONE_CREDS from fuelweb_test.settings import PATH_TO_CERT from fuelweb_test.settings import VERIFY_SSL @@ -39,11 +39,11 @@ class ContrailClient(object): controller_node_ip) insecure = not VERIFY_SSL credentials.update({'ca_cert': PATH_TO_CERT, 'insecure': insecure}) - auth = Password(auth_url=self.keystone_url, - username=KEYSTONE_CREDS['username'], - password=KEYSTONE_CREDS['password'], - tenant_name=KEYSTONE_CREDS['tenant_name']) - self._client = Session(auth=auth, verify=False) + auth = v2.Password(auth_url=self.keystone_url, + username=KEYSTONE_CREDS['username'], + password=KEYSTONE_CREDS['password'], + tenant_name=KEYSTONE_CREDS['tenant_name']) + self._client = session.Session(auth=auth, verify=False) @property def client(self): diff --git a/plugin_test/helpers/openstack.py b/plugin_test/helpers/openstack.py index 260d54159..7ab1b2b82 100644 --- a/plugin_test/helpers/openstack.py +++ b/plugin_test/helpers/openstack.py @@ -22,7 +22,7 @@ from fuelweb_test.settings import HARDWARE from fuelweb_test.helpers.checkers import check_repo_managment import settings -from tests.test_contrail_check import TestContrailCheck +from tests import test_contrail_check def assign_net_provider(obj, **options): @@ -136,7 +136,7 @@ def update_deploy_check(obj, nodes, delete=False, is_vsrx=True, ostf_params['failed_test_name'] = ostf_fail_tests obj.fuel_web.run_ostf(cluster_id=obj.cluster_id, **ostf_params) - TestContrailCheck(obj).cloud_check(['contrail']) + test_contrail_check.TestContrailCheck(obj).cloud_check(['contrail']) def wait_for_cluster_status(obj, cluster_id, diff --git a/plugin_test/run_tests.py b/plugin_test/run_tests.py index 373857186..d8c66aefb 100644 --- a/plugin_test/run_tests.py +++ b/plugin_test/run_tests.py @@ -17,11 +17,11 @@ import sys import os import re -from nose.plugins import Plugin +from nose import plugins from paramiko.transport import _join_lingering_threads -class CloseSSHConnectionsPlugin(Plugin): +class CloseSSHConnectionsPlugin(plugins.Plugin): """Closes all paramiko's ssh connections after each test case. Plugin fixes proboscis disability to run cleanup of any kind. diff --git a/plugin_test/tests/test_failover.py b/plugin_test/tests/test_failover.py index 1e78a9dd5..796e401df 100644 --- a/plugin_test/tests/test_failover.py +++ b/plugin_test/tests/test_failover.py @@ -22,8 +22,7 @@ from proboscis.asserts import assert_true from fuelweb_test import logger from fuelweb_test.helpers.decorators import log_snapshot_after_test from fuelweb_test.settings import CONTRAIL_PLUGIN_PACK_UB_PATH -from fuelweb_test.tests.base_test_case import SetupEnvironment -from fuelweb_test.tests.base_test_case import TestBasic +from fuelweb_test.tests import base_test_case from helpers import vsrx from helpers import plugin from helpers import openstack @@ -33,7 +32,7 @@ from tests.test_contrail_check import TestContrailCheck @test(groups=["plugins"]) -class FailoverTests(TestBasic): +class FailoverTests(base_test_case.TestBasic): """FailoverTests.""" pack_copy_path = '/var/www/nailgun/plugins/contrail-5.0' @@ -44,7 +43,7 @@ class FailoverTests(TestBasic): pack_path = CONTRAIL_PLUGIN_PACK_UB_PATH CONTRAIL_DISTRIBUTION = os.environ.get('CONTRAIL_DISTRIBUTION') - @test(depends_on=[SetupEnvironment.prepare_slaves_3], + @test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_3], groups=["contrail_uninstall", "contrail_failover"]) @log_snapshot_after_test def contrail_uninstall(self): @@ -106,7 +105,7 @@ class FailoverTests(TestBasic): "Plugin is not removed {}".format(plugin_name) ) - @test(depends_on=[SetupEnvironment.prepare_slaves_9], + @test(depends_on=[base_test_case.SetupEnvironment.prepare_slaves_9], groups=["contrail_ha_with_node_problems", "contrail_failover"]) @log_snapshot_after_test def contrail_ha_with_node_problems(self):