From 71d51b0c0a8ded85da120c117713b7de7cc8a8ef Mon Sep 17 00:00:00 2001 From: Alexander Nevenchannyy Date: Wed, 5 Aug 2015 22:10:13 +0300 Subject: [PATCH] Move rally/objects -> rally/common/objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no need to have objects directory on the top level. They are quite rare changed and in most case one don’t need to know about internal details of it to fulfill their task. So hiding these directory under common/* makes perfect sense Change-Id: Id77bec4e417d61470c9adfd7e43cc50975d76775 --- rally/plugins/openstack/context/keystone/users.py | 2 +- tests/hacking/checks.py | 15 ++++++++------- tests/unit/fakes.py | 2 +- .../openstack/context/keystone/test_users.py | 2 +- tests/unit/test_hacking.py | 13 +++++++------ 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/rally/plugins/openstack/context/keystone/users.py b/rally/plugins/openstack/context/keystone/users.py index f32d7035..27697a14 100644 --- a/rally/plugins/openstack/context/keystone/users.py +++ b/rally/plugins/openstack/context/keystone/users.py @@ -21,10 +21,10 @@ from oslo_config import cfg from rally.common import broker from rally.common.i18n import _ from rally.common import log as logging +from rally.common import objects from rally.common import utils as rutils from rally import consts from rally import exceptions -from rally import objects from rally import osclients from rally.plugins.openstack.wrappers import keystone from rally.plugins.openstack.wrappers import network diff --git a/tests/hacking/checks.py b/tests/hacking/checks.py index 232ae6f4..3291f841 100644 --- a/tests/hacking/checks.py +++ b/tests/hacking/checks.py @@ -261,19 +261,20 @@ def assert_equal_in(logical_line, filename): @skip_ignored_lines def check_no_direct_rally_objects_import(logical_line, filename): - """Check if rally.objects are properly imported. + """Check if rally.common.objects are properly imported. - If you import "from rally import objects" you are able to use objects - directly like objects.Task. + If you import "from rally.common import objects" you are able to use + objects directly like objects.Task. N340 """ - if filename == "./rally/objects/__init__.py": + if filename == "./rally/common/objects/__init__.py": return - if (logical_line.startswith("from rally.objects") - or logical_line.startswith("import rally.objects.")): - yield (0, "N340: Import objects module: `from rally import objects`. " + if (logical_line.startswith("from rally.common.objects") + or logical_line.startswith("import rally.common.objects.")): + yield (0, "N340: Import objects module:" + "`from rally.common import objects`. " "After that you can use directly objects e.g. objects.Task") diff --git a/tests/unit/fakes.py b/tests/unit/fakes.py index d58e09e4..0c6f9bf4 100644 --- a/tests/unit/fakes.py +++ b/tests/unit/fakes.py @@ -27,9 +27,9 @@ from novaclient import exceptions as nova_exceptions import six from swiftclient import exceptions as swift_exceptions +from rally.common import objects from rally.common import utils as rally_utils from rally import consts -from rally import objects from rally.task import context from rally.task.scenarios import base diff --git a/tests/unit/plugins/openstack/context/keystone/test_users.py b/tests/unit/plugins/openstack/context/keystone/test_users.py index 6a8a6848..b780f9ca 100644 --- a/tests/unit/plugins/openstack/context/keystone/test_users.py +++ b/tests/unit/plugins/openstack/context/keystone/test_users.py @@ -15,9 +15,9 @@ import mock +from rally.common import objects from rally import consts from rally import exceptions -from rally import objects from rally.plugins.openstack.context.keystone import users from tests.unit import test diff --git a/tests/unit/test_hacking.py b/tests/unit/test_hacking.py index 21ea3696..a4589156 100644 --- a/tests/unit/test_hacking.py +++ b/tests/unit/test_hacking.py @@ -205,17 +205,18 @@ class HackingTestCase(test.TestCase): self._assert_bad_samples(checks.assert_equal_in, bad_lines) def test_check_no_direct_rally_objects_import(self): - bad_imports = ["from rally.objects import task", - "import rally.objects.task"] + bad_imports = ["from rally.common.objects import task", + "import rally.common.objects.task"] self._assert_bad_samples(checks.check_no_direct_rally_objects_import, bad_imports) - self._assert_good_samples(checks.check_no_direct_rally_objects_import, - bad_imports, - module_file="./rally/objects/__init__.py") + self._assert_good_samples( + checks.check_no_direct_rally_objects_import, + bad_imports, + module_file="./rally/common/objects/__init__.py") - good_imports = ["from rally import objects"] + good_imports = ["from rally.common import objects"] self._assert_good_samples(checks.check_no_direct_rally_objects_import, good_imports)