From 67428d28788aa5af50d99a9abfae7125868f5bbf Mon Sep 17 00:00:00 2001 From: hujie Date: Tue, 1 Nov 2016 11:10:22 +0800 Subject: [PATCH] Clean imports in code The imports that don't match[1], There are still some left. [1] http://docs.openstack.org/developer/hacking/#imports [2] https://review.openstack.org/#/c/387781/ Change-Id: I292a0154e075e5cec4edde2609edf1712a1e43f4 --- dragonflow/tests/fullstack/test_l3_flows.py | 8 ++++---- dragonflow/tests/unit/test_db_store.py | 4 ++-- dragonflow/tests/unit/test_etcd_driver.py | 11 +++++------ dragonflow/tests/unit/test_ryu_base_app.py | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/dragonflow/tests/fullstack/test_l3_flows.py b/dragonflow/tests/fullstack/test_l3_flows.py index 96e0122aa..84c4a03d8 100644 --- a/dragonflow/tests/fullstack/test_l3_flows.py +++ b/dragonflow/tests/fullstack/test_l3_flows.py @@ -10,13 +10,12 @@ # License for the specific language governing permissions and limitations # under the License. -from random import randint +import random from dragonflow.controller.common import constants as const from dragonflow.tests.common import app_testing_objects from dragonflow.tests.common import constants as test_const from dragonflow.tests.common import utils -from dragonflow.tests.common.utils import OvsFlowsParser from dragonflow.tests.fullstack import test_base @@ -42,7 +41,8 @@ class TestL3Flows(test_base.DFTestBase): def test_router_add_route(self): lport = self.port1.port.get_logical_port() ip1 = lport.get_ip() - dest = "10.{}.{}.0/24".format(randint(0, 254), randint(0, 254)) + dest = "10.{}.{}.0/24".format( + random.randint(0, 254), random.randint(0, 254)) body = { "routes": [ { @@ -76,7 +76,7 @@ class TestL3Flows(test_base.DFTestBase): def _get_route_flows(self, nw_src, nw_dst): match = 'nw_src=' + nw_src + ',nw_dst=' + nw_dst - ovs_flows_parser = OvsFlowsParser() + ovs_flows_parser = utils.OvsFlowsParser() flows = ovs_flows_parser.dump(self.integration_bridge) flows = [flow for flow in flows if flow['table'] == str(const.L3_LOOKUP_TABLE) and diff --git a/dragonflow/tests/unit/test_db_store.py b/dragonflow/tests/unit/test_db_store.py index d8912b370..0cd3f268f 100644 --- a/dragonflow/tests/unit/test_db_store.py +++ b/dragonflow/tests/unit/test_db_store.py @@ -15,14 +15,14 @@ import mock -from dragonflow.db.db_store import DbStore +from dragonflow.db import db_store from dragonflow.tests import base as tests_base class TestDbStore(tests_base.BaseTestCase): def setUp(self): tests_base.BaseTestCase.setUp(self) - self.db_store = DbStore() + self.db_store = db_store.DbStore() def test_network_id(self): self.db_store.set_network_id('ldp1', 'value1') diff --git a/dragonflow/tests/unit/test_etcd_driver.py b/dragonflow/tests/unit/test_etcd_driver.py index b0c038a21..91ce88a73 100644 --- a/dragonflow/tests/unit/test_etcd_driver.py +++ b/dragonflow/tests/unit/test_etcd_driver.py @@ -12,7 +12,6 @@ import mock from dragonflow.db.drivers import etcd_db_driver -from dragonflow.db.drivers.etcd_db_driver import _parse_hosts from dragonflow.tests import base as tests_base @@ -21,32 +20,32 @@ class TestEtcdDB(tests_base.BaseTestCase): def test_parse_none(self): fake_host = [] expected = () - output = _parse_hosts(fake_host) + output = etcd_db_driver._parse_hosts(fake_host) self.assertEqual(expected, output) def test_parse_empty(self): fake_host = [""] expected = () - output = _parse_hosts(fake_host) + output = etcd_db_driver._parse_hosts(fake_host) self.assertEqual(expected, output) def test_parse_one_host(self): fake_host = ['127.0.0.1:80'] expected = (('127.0.0.1', 80),) - output = _parse_hosts(fake_host) + output = etcd_db_driver._parse_hosts(fake_host) self.assertEqual(expected, output) def test_parse_multiple_hosts(self): fake_host = ['127.0.0.1:80', '192.168.0.1:8080'] expected = (('127.0.0.1', 80), ('192.168.0.1', 8080)) - output = _parse_hosts(fake_host) + output = etcd_db_driver._parse_hosts(fake_host) self.assertEqual(expected, output) def test_parse_multiple_hosts_invalid(self): fake_host = ['127.0.0.1:80', '192.168.0.1'] expected = (('127.0.0.1', 80),) with mock.patch.object(etcd_db_driver.LOG, 'error') as log_err: - output = _parse_hosts(fake_host) + output = etcd_db_driver._parse_hosts(fake_host) self.assertEqual(expected, output) log_err.assert_called_once_with( u'The host string %s is invalid.', '192.168.0.1') diff --git a/dragonflow/tests/unit/test_ryu_base_app.py b/dragonflow/tests/unit/test_ryu_base_app.py index 2d1f030b2..5d49ab5cf 100644 --- a/dragonflow/tests/unit/test_ryu_base_app.py +++ b/dragonflow/tests/unit/test_ryu_base_app.py @@ -15,7 +15,7 @@ import mock -from dragonflow.controller.ryu_base_app import RyuDFAdapter +from dragonflow.controller import ryu_base_app from dragonflow.tests import base as tests_base @@ -29,7 +29,7 @@ class TestRyuDFAdapter(tests_base.BaseTestCase): def setUp(self): super(TestRyuDFAdapter, self).setUp() self.db_store = mock.Mock() - self.ryu_df_adapter = RyuDFAdapter(db_store=self.db_store) + self.ryu_df_adapter = ryu_base_app.RyuDFAdapter(db_store=self.db_store) self.mock_app = mock.Mock(spec=[ 'update_logical_switch', 'remove_logical_switch',