Move rally/objects -> rally/common/objects

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
This commit is contained in:
Alexander Nevenchannyy 2015-08-05 22:10:13 +03:00
parent 09b1a0106c
commit 06320d095a
38 changed files with 116 additions and 111 deletions

View File

@ -23,10 +23,10 @@ import jsonschema
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import objects
from rally import consts
from rally.deployment import engine as deploy_engine
from rally import exceptions
from rally import objects
from rally import osclients
from rally.task import engine
from rally.verification.tempest import tempest

View File

@ -33,9 +33,9 @@ from rally.cli import envutils
from rally.common import db
from rally.common import fileutils
from rally.common.i18n import _
from rally.common import objects
from rally.common import utils
from rally import exceptions
from rally import objects
from rally import osclients
from rally import plugins

View File

@ -21,8 +21,8 @@ from rally.cli import cliutils
from rally.cli import envutils
from rally.common import db
from rally.common.i18n import _
from rally.common import objects
from rally.common import utils
from rally import objects
from rally import osclients

View File

@ -33,10 +33,10 @@ from rally.common import fileutils
from rally.common.i18n import _
from rally.common import junit
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 plugins
from rally.task.processing import plot
from rally.task.processing import utils

View File

@ -27,9 +27,9 @@ from rally.cli import envutils
from rally.common import db
from rally.common import fileutils
from rally.common.i18n import _
from rally.common import objects
from rally import consts
from rally import exceptions
from rally import objects
from rally.verification.tempest import diff
from rally.verification.tempest import json2html

View File

@ -14,7 +14,7 @@
# under the License.
"""Contains the Rally objects."""
from rally.objects.deploy import Deployment # noqa
from rally.objects.endpoint import Endpoint # noqa
from rally.objects.task import Task # noqa
from rally.objects.verification import Verification # noqa
from rally.common.objects.deploy import Deployment # noqa
from rally.common.objects.endpoint import Endpoint # noqa
from rally.common.objects.task import Task # noqa
from rally.common.objects.verification import Verification # noqa

View File

@ -19,11 +19,11 @@ import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import objects
from rally.common import utils
from rally import consts
from rally.deployment import engine
from rally.deployment.serverprovider import provider
from rally import objects
LOG = logging.getLogger(__name__)

View File

@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import objects
from rally import consts
from rally.deployment import engine
from rally import objects
@engine.configure(name="ExistingCloud")

View File

@ -14,11 +14,11 @@
# under the License.
from rally.common.i18n import _
from rally.common import objects
from rally import consts
from rally.deployment import engine
from rally.deployment.fuel import fuelclient
from rally import exceptions
from rally import objects
FILTER_SCHEMA = {

View File

@ -20,12 +20,12 @@ import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import objects
from rally.common import utils
from rally.deployment import engine
from rally.deployment.serverprovider import provider
from rally.deployment.serverprovider.providers import lxc
from rally import exceptions
from rally import objects
LOG = logging.getLogger(__name__)
START_SCRIPT = "start.sh"

View File

@ -19,9 +19,9 @@ from six.moves.urllib import parse
import rally
from rally.common import db
from rally.common import objects
from rally import consts
from rally.deployment import engine
from rally import objects
@engine.configure(name="MultihostEngine")

View File

@ -21,9 +21,9 @@ import novaclient.exceptions
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import objects
from rally.deployment.serverprovider import provider
from rally import exceptions
from rally import objects
from rally import osclients
from rally.task import utils

View File

@ -19,9 +19,9 @@ from oslo_config import cfg
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import objects
from rally import consts
from rally import exceptions
from rally import objects
CONF = cfg.CONF

View File

@ -264,13 +264,14 @@ def cleanup(names=None, admin_required=None, admin=None, users=None):
:param admin_required: If None -> return all plugins
If True -> return only admin plugins
If False -> return only non admin plugins
:param admin: rally.objects.Endpoint that corresponds to OpenStack admin.
:param admin: rally.common.objects.Endpoint that corresponds to OpenStack
admin.
:param users: List of OpenStack users that was used during benchmarking.
Every user has next structure:
{
"id": <uuid1>,
"tenant_id": <uuid2>,
"endpoint": <rally.objects.Endpoint>
"endpoint": <rally.common.objects.Endpoint>
}
"""

View File

@ -15,8 +15,8 @@
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 objects
from rally import osclients
from rally.task import context

View File

@ -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

View File

@ -23,10 +23,10 @@ import six
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.context.keystone import existing_users
from rally.plugins.openstack.context.keystone import users as users_ctx

View File

@ -23,9 +23,9 @@ from novaclient import exceptions as nova_exc
import six
from rally.common.i18n import _
from rally.common import objects
from rally import consts
from rally import exceptions
from rally import objects
from rally import osclients
from rally.plugins.openstack.context.nova import flavors as flavors_ctx
from rally.task import types

View File

@ -26,8 +26,8 @@ from six.moves.urllib import parse
from rally.common import db
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import objects
from rally import exceptions
from rally import objects
from rally import osclients

View File

@ -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")

View File

@ -20,9 +20,9 @@ import mock
from rally.cli.commands import deployment
from rally.cli import envutils
from rally.common import objects
from rally import consts
from rally import exceptions
from rally import objects
from tests.unit import fakes
from tests.unit import test

View File

@ -21,9 +21,9 @@ import mock
import six
from rally.cli.commands import verify
from rally.common import objects
from rally import consts
from rally import exceptions
from rally import objects
from tests.unit import test
@ -116,7 +116,7 @@ class VerifyCommandsTestCase(test.TestCase):
@mock.patch("rally.cli.cliutils.print_list")
@mock.patch("rally.common.db.verification_get")
@mock.patch("rally.common.db.verification_result_get")
@mock.patch("rally.objects.Verification")
@mock.patch("rally.common.objects.Verification")
def test_show(self, mock_objects_verification,
mock_verification_result_get, mock_verification_get,
mock_print_list):

View File

@ -18,8 +18,8 @@
import mock
from rally.common import objects
from rally import consts
from rally import objects
from tests.unit import test
@ -41,28 +41,28 @@ class DeploymentTestCase(test.TestCase):
"info": {"key": "value"},
}
@mock.patch("rally.objects.deploy.db.deployment_create")
@mock.patch("rally.common.objects.deploy.db.deployment_create")
def test_init_with_create(self, mock_deployment_create):
mock_deployment_create.return_value = self.deployment
deploy = objects.Deployment()
mock_deployment_create.assert_called_once_with({})
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
@mock.patch("rally.objects.deploy.db.deployment_create")
@mock.patch("rally.common.objects.deploy.db.deployment_create")
def test_init_without_create(self, mock_deployment_create):
deploy = objects.Deployment(deployment=self.deployment)
self.assertFalse(mock_deployment_create.called)
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
@mock.patch("rally.objects.deploy.db.deployment_get")
@mock.patch("rally.common.objects.deploy.db.deployment_get")
def test_get(self, mock_deployment_get):
mock_deployment_get.return_value = self.deployment
deploy = objects.Deployment.get(self.deployment["uuid"])
mock_deployment_get.assert_called_once_with(self.deployment["uuid"])
self.assertEqual(deploy["uuid"], self.deployment["uuid"])
@mock.patch("rally.objects.deploy.db.deployment_delete")
@mock.patch("rally.objects.deploy.db.deployment_create")
@mock.patch("rally.common.objects.deploy.db.deployment_delete")
@mock.patch("rally.common.objects.deploy.db.deployment_create")
def test_create_and_delete(self, mock_deployment_create,
mock_deployment_delete):
mock_deployment_create.return_value = self.deployment
@ -70,13 +70,13 @@ class DeploymentTestCase(test.TestCase):
deploy.delete()
mock_deployment_delete.assert_called_once_with(self.deployment["uuid"])
@mock.patch("rally.objects.deploy.db.deployment_delete")
@mock.patch("rally.common.objects.deploy.db.deployment_delete")
def test_delete_by_uuid(self, mock_deployment_delete):
objects.Deployment.delete_by_uuid(self.deployment["uuid"])
mock_deployment_delete.assert_called_once_with(self.deployment["uuid"])
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.objects.deploy.db.deployment_create")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_create")
def test_update(self, mock_deployment_create, mock_deployment_update):
mock_deployment_create.return_value = self.deployment
mock_deployment_update.return_value = {"opt": "val2"}
@ -86,7 +86,7 @@ class DeploymentTestCase(test.TestCase):
self.deployment["uuid"], {"opt": "val2"})
self.assertEqual(deploy["opt"], "val2")
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
def test_update_status(self, mock_deployment_update):
mock_deployment_update.return_value = self.deployment
deploy = objects.Deployment(deployment=self.deployment)
@ -96,7 +96,7 @@ class DeploymentTestCase(test.TestCase):
{"status": consts.DeployStatus.DEPLOY_FAILED},
)
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
def test_update_name(self, mock_deployment_update):
mock_deployment_update.return_value = self.deployment
deploy = objects.Deployment(deployment=self.deployment)
@ -106,7 +106,7 @@ class DeploymentTestCase(test.TestCase):
{"name": "new_name"},
)
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
def test_update_config(self, mock_deployment_update):
mock_deployment_update.return_value = self.deployment
deploy = objects.Deployment(deployment=self.deployment)
@ -116,7 +116,7 @@ class DeploymentTestCase(test.TestCase):
{"config": {"opt": "val"}},
)
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
def test_update_endpoints(self, mock_deployment_update):
mock_deployment_update.return_value = self.deployment
deploy = objects.Deployment(deployment=self.deployment)
@ -142,7 +142,7 @@ class DeploymentTestCase(test.TestCase):
"users": expected_users
})
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
def test_update_empty_endpoints(self, mock_deployment_update):
mock_deployment_update.return_value = self.deployment
deploy = objects.Deployment(deployment=self.deployment)
@ -150,7 +150,7 @@ class DeploymentTestCase(test.TestCase):
mock_deployment_update.assert_called_once_with(
self.deployment["uuid"], {"admin": {}, "users": []})
@mock.patch("rally.objects.deploy.db.resource_create")
@mock.patch("rally.common.objects.deploy.db.resource_create")
def test_add_resource(self, mock_resource_create):
mock_resource_create.return_value = self.resource
deploy = objects.Deployment(deployment=self.deployment)
@ -164,12 +164,12 @@ class DeploymentTestCase(test.TestCase):
"info": {"key": "value"},
})
@mock.patch("rally.objects.task.db.resource_delete")
@mock.patch("rally.common.objects.task.db.resource_delete")
def test_delete(self, mock_resource_delete):
objects.Deployment.delete_resource(42)
mock_resource_delete.assert_called_once_with(42)
@mock.patch("rally.objects.task.db.resource_get_all")
@mock.patch("rally.common.objects.task.db.resource_get_all")
def test_get_resources(self, mock_resource_get_all):
mock_resource_get_all.return_value = [self.resource]
deploy = objects.Deployment(deployment=self.deployment)
@ -177,8 +177,8 @@ class DeploymentTestCase(test.TestCase):
self.assertEqual(len(resources), 1)
self.assertEqual(resources[0]["id"], self.resource["id"])
@mock.patch("rally.objects.deploy.datetime.datetime")
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.datetime.datetime")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
def test_update_set_started(self, mock_deployment_update, mock_datetime):
mock_datetime.now = mock.Mock(return_value="fake_time")
mock_deployment_update.return_value = self.deployment
@ -190,8 +190,8 @@ class DeploymentTestCase(test.TestCase):
"status": consts.DeployStatus.DEPLOY_STARTED}
)
@mock.patch("rally.objects.deploy.datetime.datetime")
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.datetime.datetime")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
def test_update_set_completed(self, mock_deployment_update, mock_datetime):
mock_datetime.now = mock.Mock(return_value="fake_time")
mock_deployment_update.return_value = self.deployment

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import objects
from rally import consts
from rally import objects
from tests.unit import test

View File

@ -19,8 +19,8 @@ import json
import mock
from rally.common import objects
from rally import consts
from rally import objects
from tests.unit import test
@ -33,7 +33,7 @@ class TaskTestCase(test.TestCase):
"verification_log": "",
}
@mock.patch("rally.objects.task.db.task_create")
@mock.patch("rally.common.objects.task.db.task_create")
def test_init_with_create(self, mock_task_create):
mock_task_create.return_value = self.task
task = objects.Task(status=consts.TaskStatus.FAILED)
@ -41,29 +41,30 @@ class TaskTestCase(test.TestCase):
"status": consts.TaskStatus.FAILED})
self.assertEqual(task["uuid"], self.task["uuid"])
@mock.patch("rally.objects.task.db.task_create")
@mock.patch("rally.common.objects.task.db.task_create")
def test_init_without_create(self, mock_task_create):
task = objects.Task(task=self.task)
self.assertFalse(mock_task_create.called)
self.assertEqual(task["uuid"], self.task["uuid"])
@mock.patch("rally.objects.task.uuid.uuid4", return_value="some_uuid")
@mock.patch("rally.objects.task.db.task_create")
@mock.patch("rally.common.objects.task.uuid.uuid4",
return_value="some_uuid")
@mock.patch("rally.common.objects.task.db.task_create")
def test_init_with_fake_true(self, mock_task_create, mock_uuid4):
task = objects.Task(fake=True)
self.assertFalse(mock_task_create.called)
self.assertTrue(mock_uuid4.called)
self.assertEqual(task["uuid"], mock_uuid4.return_value)
@mock.patch("rally.objects.task.db.task_get")
@mock.patch("rally.common.objects.task.db.task_get")
def test_get(self, mock_task_get):
mock_task_get.return_value = self.task
task = objects.Task.get(self.task["uuid"])
mock_task_get.assert_called_once_with(self.task["uuid"])
self.assertEqual(task["uuid"], self.task["uuid"])
@mock.patch("rally.objects.task.db.task_delete")
@mock.patch("rally.objects.task.db.task_create")
@mock.patch("rally.common.objects.task.db.task_delete")
@mock.patch("rally.common.objects.task.db.task_create")
def test_create_and_delete(self, mock_task_create, mock_task_delete):
mock_task_create.return_value = self.task
task = objects.Task()
@ -71,8 +72,8 @@ class TaskTestCase(test.TestCase):
mock_task_delete.assert_called_once_with(
self.task["uuid"], status=None)
@mock.patch("rally.objects.task.db.task_delete")
@mock.patch("rally.objects.task.db.task_create")
@mock.patch("rally.common.objects.task.db.task_delete")
@mock.patch("rally.common.objects.task.db.task_create")
def test_create_and_delete_status(self, mock_task_create,
mock_task_delete):
mock_task_create.return_value = self.task
@ -81,20 +82,20 @@ class TaskTestCase(test.TestCase):
mock_task_delete.assert_called_once_with(
self.task["uuid"], status=consts.TaskStatus.FINISHED)
@mock.patch("rally.objects.task.db.task_delete")
@mock.patch("rally.common.objects.task.db.task_delete")
def test_delete_by_uuid(self, mock_task_delete):
objects.Task.delete_by_uuid(self.task["uuid"])
mock_task_delete.assert_called_once_with(
self.task["uuid"], status=None)
@mock.patch("rally.objects.task.db.task_delete")
@mock.patch("rally.common.objects.task.db.task_delete")
def test_delete_by_uuid_status(self, mock_task_delete):
objects.Task.delete_by_uuid(self.task["uuid"],
consts.TaskStatus.FINISHED)
mock_task_delete.assert_called_once_with(
self.task["uuid"], status=consts.TaskStatus.FINISHED)
@mock.patch("rally.objects.task.db.task_list",
@mock.patch("rally.common.objects.task.db.task_list",
return_value=[{"uuid": "a",
"created_at": "b",
"status": consts.TaskStatus.FAILED,
@ -108,8 +109,8 @@ class TaskTestCase(test.TestCase):
self.assertEqual(mock_db_task_list.return_value["uuis"],
tasks[0]["uuid"])
@mock.patch("rally.objects.deploy.db.task_update")
@mock.patch("rally.objects.task.db.task_create")
@mock.patch("rally.common.objects.deploy.db.task_update")
@mock.patch("rally.common.objects.task.db.task_create")
def test_update(self, mock_task_create, mock_task_update):
mock_task_create.return_value = self.task
mock_task_update.return_value = {"opt": "val2"}
@ -119,7 +120,7 @@ class TaskTestCase(test.TestCase):
self.task["uuid"], {"opt": "val2"})
self.assertEqual(deploy["opt"], "val2")
@mock.patch("rally.objects.task.db.task_update")
@mock.patch("rally.common.objects.task.db.task_update")
def test_update_status(self, mock_task_update):
mock_task_update.return_value = self.task
task = objects.Task(task=self.task)
@ -129,7 +130,7 @@ class TaskTestCase(test.TestCase):
{"status": consts.TaskStatus.FINISHED},
)
@mock.patch("rally.objects.task.db.task_update")
@mock.patch("rally.common.objects.task.db.task_update")
def test_update_verification_log(self, mock_task_update):
mock_task_update.return_value = self.task
task = objects.Task(task=self.task)
@ -139,7 +140,7 @@ class TaskTestCase(test.TestCase):
{"verification_log": json.dumps({"a": "fake"})}
)
@mock.patch("rally.objects.task.db.task_result_get_all_by_uuid",
@mock.patch("rally.common.objects.task.db.task_result_get_all_by_uuid",
return_value="foo_results")
def test_get_results(self, mock_task_result_get_all_by_uuid):
task = objects.Task(task=self.task)
@ -148,14 +149,14 @@ class TaskTestCase(test.TestCase):
self.task["uuid"])
self.assertEqual(results, "foo_results")
@mock.patch("rally.objects.task.db.task_result_create")
@mock.patch("rally.common.objects.task.db.task_result_create")
def test_append_results(self, mock_task_result_create):
task = objects.Task(task=self.task)
task.append_results("opt", "val")
mock_task_result_create.assert_called_once_with(
self.task["uuid"], "opt", "val")
@mock.patch("rally.objects.task.db.task_update")
@mock.patch("rally.common.objects.task.db.task_update")
def test_set_failed(self, mock_task_update):
mock_task_update.return_value = self.task
task = objects.Task(task=self.task)

View File

@ -15,7 +15,7 @@
import mock
from rally import objects
from rally.common import objects
from tests.unit import test
from tests.unit.verification import fakes
@ -37,13 +37,13 @@ class VerificationTestCase(test.TestCase):
"name": "bar_test[gate,negative]",
"time": "0.29"}]}}
@mock.patch("rally.objects.verification.db.verification_create")
@mock.patch("rally.common.objects.verification.db.verification_create")
def test_init_with_create(self, mock_verification_create):
objects.Verification(deployment_uuid="some_deployment_uuid")
mock_verification_create.assert_called_once_with(
"some_deployment_uuid")
@mock.patch("rally.objects.verification.db.verification_create")
@mock.patch("rally.common.objects.verification.db.verification_create")
def test_init_without_create(self, mock_verification_create):
verification = objects.Verification(db_object=self.db_obj)
@ -53,20 +53,20 @@ class VerificationTestCase(test.TestCase):
self.assertEqual(self.db_obj["errors"], verification.errors)
self.assertEqual(self.db_obj["time"], verification.time)
@mock.patch("rally.objects.verification.db.verification_get")
@mock.patch("rally.common.objects.verification.db.verification_get")
def test_get(self, mock_verification_get):
objects.Verification.get(self.db_obj["id"])
mock_verification_get.assert_called_once_with(self.db_obj["id"])
@mock.patch("rally.objects.verification.db.verification_delete")
@mock.patch("rally.objects.verification.db.verification_create")
@mock.patch("rally.common.objects.verification.db.verification_delete")
@mock.patch("rally.common.objects.verification.db.verification_create")
def test_create_and_delete(self, mock_verification_create,
mock_verification_delete):
verification = objects.Verification(db_object=self.db_obj)
verification.delete()
mock_verification_delete.assert_called_once_with(self.db_obj["uuid"])
@mock.patch("rally.objects.verification.db.verification_update")
@mock.patch("rally.common.objects.verification.db.verification_update")
def test_set_failed(self, mock_verification_update):
mock_verification_update.return_value = self.db_obj
verification = objects.Verification(db_object=self.db_obj)
@ -74,8 +74,9 @@ class VerificationTestCase(test.TestCase):
mock_verification_update.assert_called_once_with(
self.db_obj["uuid"], {"status": "failed"})
@mock.patch("rally.objects.verification.db.verification_result_create")
@mock.patch("rally.objects.verification.db.verification_update")
@mock.patch(
("rally.common.objects.verification.db.verification_result_create"))
@mock.patch("rally.common.objects.verification.db.verification_update")
def test_finish_verification(self, mock_verification_update,
mock_verification_result_create):
verification = objects.Verification(db_object=self.db_obj)

View File

@ -15,8 +15,8 @@
import mock
from rally.common import objects
from rally.deployment import engine
from rally import objects
from tests.unit import test
MOD = "rally.deployment.engines.lxc."

View File

@ -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

View File

@ -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

View File

@ -103,9 +103,9 @@ class TaskAPITestCase(test.TestCase):
def test_render_template_missing_args(self):
self.assertRaises(TypeError, api.Task.render_template, "{{a}}")
@mock.patch("rally.objects.Deployment.get",
@mock.patch("rally.common.objects.Deployment.get",
return_value={"uuid": "b0d9cd6c-2c94-4417-a238-35c7019d0257"})
@mock.patch("rally.objects.Task")
@mock.patch("rally.common.objects.Task")
def test_create(self, mock_task, mock_deployment_get):
tag = "a"
api.Task.create(mock_deployment_get.return_value["uuid"], tag)
@ -160,14 +160,14 @@ class TaskAPITestCase(test.TestCase):
def test_abort(self):
self.assertRaises(NotImplementedError, api.Task.abort, self.task_uuid)
@mock.patch("rally.objects.task.db.task_delete")
@mock.patch("rally.common.objects.task.db.task_delete")
def test_delete(self, mock_task_delete):
api.Task.delete(self.task_uuid)
mock_task_delete.assert_called_once_with(
self.task_uuid,
status=consts.TaskStatus.FINISHED)
@mock.patch("rally.objects.task.db.task_delete")
@mock.patch("rally.common.objects.task.db.task_delete")
def test_delete_force(self, mock_task_delete):
api.Task.delete(self.task_uuid, force=True)
mock_task_delete.assert_called_once_with(
@ -197,8 +197,8 @@ class BaseDeploymentTestCase(test.TestCase):
class DeploymentAPITestCase(BaseDeploymentTestCase):
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.objects.deploy.db.deployment_create")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_create")
@mock.patch("rally.deployment.engine.Engine.validate")
def test_create(self, mock_engine_validate,
mock_deployment_create, mock_deployment_update):
@ -214,8 +214,8 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
mock.call(self.deployment_uuid, self.endpoints)
])
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.objects.deploy.db.deployment_create")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_create")
@mock.patch("rally.deployment.engine.Engine.validate",
side_effect=jsonschema.ValidationError("ValidationError"))
def test_create_validation_error(
@ -230,7 +230,7 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
{"status": consts.DeployStatus.DEPLOY_FAILED})
@mock.patch("rally.api.LOG")
@mock.patch("rally.objects.deploy.db.deployment_create",
@mock.patch("rally.common.objects.deploy.db.deployment_create",
side_effect=exceptions.DeploymentNameExists(
deployment="fake_deploy"))
def test_create_duplication_error(self, mock_deployment_create, mock_log):
@ -238,9 +238,9 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
api.Deployment.create, self.deployment_config,
"fake_deployment")
@mock.patch("rally.objects.deploy.db.deployment_delete")
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.objects.deploy.db.deployment_get")
@mock.patch("rally.common.objects.deploy.db.deployment_delete")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_get")
def test_destroy(self, mock_deployment_get,
mock_deployment_update, mock_deployment_delete):
mock_deployment_get.return_value = self.deployment
@ -249,8 +249,8 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
mock_deployment_get.assert_called_once_with(self.deployment_uuid)
mock_deployment_delete.assert_called_once_with(self.deployment_uuid)
@mock.patch("rally.objects.deploy.db.deployment_update")
@mock.patch("rally.objects.deploy.db.deployment_get")
@mock.patch("rally.common.objects.deploy.db.deployment_update")
@mock.patch("rally.common.objects.deploy.db.deployment_get")
def test_recreate(self, mock_deployment_get, mock_deployment_update):
mock_deployment_get.return_value = self.deployment
mock_deployment_update.return_value = self.deployment
@ -260,7 +260,7 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
mock.call(self.deployment_uuid, self.endpoints)
])
@mock.patch("rally.objects.deploy.db.deployment_get")
@mock.patch("rally.common.objects.deploy.db.deployment_get")
def test_get(self, mock_deployment_get):
deployment_id = "aaaa-bbbb-cccc-dddd"
mock_deployment_get.return_value = self.deployment
@ -274,7 +274,7 @@ class VerificationAPITestCase(BaseDeploymentTestCase):
super(VerificationAPITestCase, self).setUp()
self.tempest = mock.Mock()
@mock.patch("rally.objects.Deployment.get")
@mock.patch("rally.common.objects.Deployment.get")
@mock.patch("rally.api.objects.Verification")
@mock.patch("rally.verification.tempest.tempest.Tempest")
def test_verify(self, mock_tempest, mock_verification,

View File

@ -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)

View File

@ -18,9 +18,9 @@ from keystoneclient import exceptions as keystone_exceptions
import mock
from oslo_config import cfg
from rally.common import objects
from rally import consts
from rally import exceptions
from rally import objects
from rally import osclients
from tests.unit import fakes
from tests.unit import test

View File

@ -28,7 +28,7 @@ CONF = cfg.CONF
class ConfigTestCase(test.TestCase):
@mock.patch("rally.objects.deploy.db.deployment_get")
@mock.patch("rally.common.objects.deploy.db.deployment_get")
@mock.patch("rally.osclients.Clients.services",
return_value={"test_service_type": "test_service"})
@mock.patch("rally.osclients.Clients.verified_keystone")