Merge "Move rally/objects -> rally/common/objects"
This commit is contained in:
@@ -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
|
||||
|
@@ -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")
|
||||
|
||||
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user