Rename rally.cmd to rally.cli

There is module 'cmd' in standard library, and unittest's discover
does modify sys.path when running tests. This cause errors when running
unit tests in some environments (E.g. pycharm)

Change-Id: I4fd2d271da1b7fd300fbbeb6107aa958e716fd2b
Closes-Bug: 1457162
This commit is contained in:
Sergey Skripnick 2015-05-20 22:10:22 +03:00
parent 827e41ef98
commit a9b635f62e
31 changed files with 217 additions and 217 deletions

View File

@ -534,7 +534,7 @@ def run(argv, categories):
def _generate_bash_completion_script():
from rally.cmd import main
from rally.cli import main
bash_data = """
#!/bin/bash

View File

@ -25,8 +25,8 @@ import jsonschema
import yaml
from rally import api
from rally.cmd import cliutils
from rally.cmd import envutils
from rally.cli import cliutils
from rally.cli import envutils
from rally.common import fileutils
from rally.common.i18n import _
from rally.common import utils

View File

@ -51,7 +51,7 @@ from __future__ import print_function
from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.sla import base as sla_base
from rally.cmd import cliutils
from rally.cli import cliutils
from rally.common import utils
from rally import deploy
from rally.deploy import serverprovider

View File

@ -17,8 +17,8 @@
from __future__ import print_function
from rally.cmd import cliutils
from rally.cmd import envutils
from rally.cli import cliutils
from rally.cli import envutils
from rally.common.i18n import _
from rally.common import utils
from rally import db

View File

@ -28,8 +28,8 @@ import yaml
from rally import api
from rally.benchmark.processing import plot
from rally.benchmark.processing import utils
from rally.cmd import cliutils
from rally.cmd import envutils
from rally.cli import cliutils
from rally.cli import envutils
from rally.common import fileutils
from rally.common.i18n import _
from rally.common import log as logging

View File

@ -15,10 +15,10 @@
""" Rally command: use """
from rally.cmd import cliutils
from rally.cmd.commands import deployment as cmd_deployment
from rally.cmd.commands import task
from rally.cmd.commands import verify
from rally.cli import cliutils
from rally.cli.commands import deployment as cli_deployment
from rally.cli.commands import task
from rally.cli.commands import verify
from rally.common import log as logging
@ -47,7 +47,7 @@ class UseCommands(object):
"""
LOG.warning("Deprecated command 'rally use deployment', "
"'rally deployment use' should be used instead.")
cmd_deployment.DeploymentCommands().use(deployment)
cli_deployment.DeploymentCommands().use(deployment)
@cliutils.args("--uuid", type=str, dest="task_id", required=False,
help="UUID of the task")

View File

@ -22,8 +22,8 @@ import os
import six
from rally import api
from rally.cmd import cliutils
from rally.cmd import envutils
from rally.cli import cliutils
from rally.cli import envutils
from rally.common import fileutils
from rally.common.i18n import _
from rally import consts

View File

@ -19,13 +19,13 @@ from __future__ import print_function
import sys
from rally.cmd import cliutils
from rally.cmd.commands import deployment
from rally.cmd.commands import info
from rally.cmd.commands import show
from rally.cmd.commands import task
from rally.cmd.commands import use
from rally.cmd.commands import verify
from rally.cli import cliutils
from rally.cli.commands import deployment
from rally.cli.commands import info
from rally.cli.commands import show
from rally.cli.commands import task
from rally.cli.commands import use
from rally.cli.commands import verify
categories = {

View File

@ -20,8 +20,8 @@ from __future__ import print_function
import sys
from rally import api
from rally.cmd import cliutils
from rally.cmd import envutils
from rally.cli import cliutils
from rally.cli import envutils
from rally import db

View File

@ -25,8 +25,8 @@ packages =
[entry_points]
console_scripts =
rally = rally.cmd.main:main
rally-manage = rally.cmd.manage:main
rally = rally.cli.main:main
rally-manage = rally.cli.manage:main
oslo.config.opts =
rally = rally.common.opts:list_opts

View File

@ -19,7 +19,7 @@ import unittest
import mock
from rally.cmd import envutils
from rally.cli import envutils
from tests.functional import utils
@ -71,7 +71,7 @@ class DeploymentTestCase(unittest.TestCase):
def test_check_fail(self):
with mock.patch.dict("os.environ", utils.TEST_ENV):
self.rally("deployment create --name t_create_env --fromenv")
self.assertRaises(utils.RallyCmdError, self.rally,
self.assertRaises(utils.RallyCliError, self.rally,
("deployment check"))
def test_recreate(self):
@ -89,4 +89,4 @@ class DeploymentTestCase(unittest.TestCase):
self.rally("deployment create --name t_create_env2 --fromenv")
self.rally("deployment use --deployment %s" % uuid)
current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
self.assertEqual(uuid, current_deployment)
self.assertEqual(uuid, current_deployment)

View File

@ -34,7 +34,7 @@ class InfoTestCase(unittest.TestCase):
def test_find_scenario_group_base_class(self):
# NOTE(msdubov): We shouldn't display info about base scenario classes
# containing no end-user scenarios
self.assertRaises(utils.RallyCmdError, self.rally,
self.assertRaises(utils.RallyCliError, self.rally,
("info find CeilometerScenario"))
def test_find_scenario(self):
@ -76,7 +76,7 @@ class InfoTestCase(unittest.TestCase):
self.assertIn(marker_string, self.rally("info find ExistingServer"))
def test_find_fails(self):
self.assertRaises(utils.RallyCmdError, self.rally,
self.assertRaises(utils.RallyCliError, self.rally,
("info find NonExistingStuff"))
def test_find_misspelling_truncated(self):
@ -88,7 +88,7 @@ class InfoTestCase(unittest.TestCase):
def test_find_misspelling_truncated_many_substitutions(self):
try:
self.rally("info find Nova")
except utils.RallyCmdError as e:
except utils.RallyCliError as e:
self.assertIn("NovaServers", e.output)
self.assertIn("NovaServers.boot_and_delete_server", e.output)
self.assertIn("NovaServers.snapshot_server", e.output)

View File

@ -20,7 +20,7 @@ import unittest
import mock
from rally.cmd import envutils
from rally.cli import envutils
from tests.functional import utils
@ -95,37 +95,37 @@ class TaskTestCase(unittest.TestCase):
def test_results_with_wrong_task_id(self):
rally = utils.Rally()
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task results --uuid %s" % FAKE_TASK_UUID)
def test_abort_with_wrong_task_id(self):
rally = utils.Rally()
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task abort --uuid %s" % FAKE_TASK_UUID)
def test_delete_with_wrong_task_id(self):
rally = utils.Rally()
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task delete --uuid %s" % FAKE_TASK_UUID)
def test_detailed_with_wrong_task_id(self):
rally = utils.Rally()
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task detailed --uuid %s" % FAKE_TASK_UUID)
def test_report_with_wrong_task_id(self):
rally = utils.Rally()
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task report --tasks %s" % FAKE_TASK_UUID)
def test_sla_check_with_wrong_task_id(self):
rally = utils.Rally()
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task sla_check --uuid %s" % FAKE_TASK_UUID)
def test_status_with_wrong_task_id(self):
rally = utils.Rally()
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task status --uuid %s" % FAKE_TASK_UUID)
def test_report_one_uuid(self):
@ -136,7 +136,7 @@ class TaskTestCase(unittest.TestCase):
rally("task report --out %s" % rally.gen_report_path(extension="html"))
self.assertTrue(os.path.exists(
rally.gen_report_path(extension="html")))
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task report --report %s" % FAKE_TASK_UUID)
def test_report_bunch_uuids(self):
@ -196,7 +196,7 @@ class TaskTestCase(unittest.TestCase):
rally.gen_report_path(extension="html")))
self.assertTrue(os.path.exists(
rally.gen_report_path(extension="html")))
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task report --report %s" % FAKE_TASK_UUID)
def test_delete(self):
@ -228,7 +228,7 @@ class TaskTestCase(unittest.TestCase):
self.assertIn(
"deployment_name", rally("task list --all-deployments"))
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally, "task list --status not_existing_status")
def test_list_with_print_uuids_option(self):
@ -274,7 +274,7 @@ class TaskTestCase(unittest.TestCase):
deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
cfg = {"invalid": "config"}
config = utils.TaskConfig(cfg)
self.assertRaises(utils.RallyCmdError,
self.assertRaises(utils.RallyCliError,
rally,
("task validate --task %(task_file)s "
"--deployment %(deployment_id)s") %
@ -556,7 +556,7 @@ class SLATestCase(unittest.TestCase):
cfg = self._get_sample_task_config(max_seconds_per_iteration=0.001)
config = utils.TaskConfig(cfg)
rally("task start --task %s" % config.filename)
self.assertRaises(utils.RallyCmdError, rally, "task sla_check")
self.assertRaises(utils.RallyCliError, rally, "task sla_check")
def test_sla_success(self):
rally = utils.Rally()
@ -609,7 +609,7 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
]
try:
rally("task sla_check --json", getjson=True)
except utils.RallyCmdError as expected_error:
except utils.RallyCliError as expected_error:
self.assertEqual(json.loads(expected_error.output), expected)
else:
self.fail("`rally task sla_check` command should return non-zero "
@ -637,7 +637,7 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
]
try:
rally("task sla_check --json", getjson=True)
except utils.RallyCmdError as expected_error:
except utils.RallyCliError as expected_error:
self.assertEqual(json.loads(expected_error.output), expected)
else:
self.fail("`rally task sla_check` command should return non-zero "

View File

@ -18,7 +18,7 @@ import unittest
import mock
from rally.cmd import envutils
from rally.cli import envutils
from tests.functional import utils
@ -34,7 +34,7 @@ class CliUtilsTestCase(unittest.TestCase):
output).group("uuid")
def test_missing_argument(self):
with self.assertRaises(utils.RallyCmdError) as e:
with self.assertRaises(utils.RallyCliError) as e:
self.rally("use task")
self.assertIn("--uuid", e.exception.output)

View File

@ -45,7 +45,7 @@ class TestTaskSamples(unittest.TestCase):
continue
try:
rally("task validate --task %s" % full_path)
except utils.RallyCmdError as e:
except utils.RallyCliError as e:
if re.search(
"[Ss]ervice is not available", e.output) is None:
raise e

View File

@ -34,7 +34,7 @@ TEST_ENV = {
DEPLOYMENT_FILE = "/tmp/rally_functests_main_deployment.json"
class RallyCmdError(Exception):
class RallyCliError(Exception):
def __init__(self, code, output):
self.code = code
@ -184,4 +184,4 @@ class Rally(object):
return json.loads(output)
return output
except subprocess.CalledProcessError as e:
raise RallyCmdError(e.returncode, e.output)
raise RallyCliError(e.returncode, e.output)

View File

@ -17,8 +17,8 @@ import os
import mock
from rally.cmd.commands import deployment
from rally.cmd import envutils
from rally.cli.commands import deployment
from rally.cli import envutils
from rally import consts
from rally import exceptions
from rally import objects
@ -32,9 +32,9 @@ class DeploymentCommandsTestCase(test.TestCase):
self.deployment = deployment.DeploymentCommands()
@mock.patch.dict(os.environ, {"RALLY_DEPLOYMENT": "my_deployment_id"})
@mock.patch("rally.cmd.commands.deployment.DeploymentCommands.list")
@mock.patch("rally.cmd.commands.deployment.api.Deployment.create")
@mock.patch("rally.cmd.commands.deployment.open",
@mock.patch("rally.cli.commands.deployment.DeploymentCommands.list")
@mock.patch("rally.cli.commands.deployment.api.Deployment.create")
@mock.patch("rally.cli.commands.deployment.open",
mock.mock_open(read_data="{\"some\": \"json\"}"),
create=True)
def test_create(self, mock_create, mock_list):
@ -48,8 +48,8 @@ class DeploymentCommandsTestCase(test.TestCase):
"OS_REGION_NAME": "fake_region_name",
"OS_ENDPOINT": "fake_endpoint",
"RALLY_DEPLOYMENT": "fake_deployment_id"})
@mock.patch("rally.cmd.commands.deployment.api.Deployment.create")
@mock.patch("rally.cmd.commands.deployment.DeploymentCommands.list")
@mock.patch("rally.cli.commands.deployment.api.Deployment.create")
@mock.patch("rally.cli.commands.deployment.DeploymentCommands.list")
def test_createfromenv(self, mock_list, mock_create):
self.deployment.create("from_env", True)
mock_create.assert_called_once_with(
@ -67,11 +67,11 @@ class DeploymentCommandsTestCase(test.TestCase):
"from_env"
)
@mock.patch("rally.cmd.commands.deployment.DeploymentCommands.list")
@mock.patch("rally.cmd.commands.deployment.DeploymentCommands.use")
@mock.patch("rally.cmd.commands.deployment.api.Deployment.create",
@mock.patch("rally.cli.commands.deployment.DeploymentCommands.list")
@mock.patch("rally.cli.commands.deployment.DeploymentCommands.use")
@mock.patch("rally.cli.commands.deployment.api.Deployment.create",
return_value=dict(uuid="uuid"))
@mock.patch("rally.cmd.commands.deployment.open",
@mock.patch("rally.cli.commands.deployment.open",
mock.mock_open(read_data="{\"uuid\": \"uuid\"}"),
create=True)
def test_create_and_use(self, mock_create, mock_use_deployment,
@ -81,34 +81,34 @@ class DeploymentCommandsTestCase(test.TestCase):
mock_create.assert_called_once_with({"uuid": "uuid"}, "fake_deploy")
mock_use_deployment.assert_called_once_with("uuid")
@mock.patch("rally.cmd.commands.deployment.api.Deployment.recreate")
@mock.patch("rally.cli.commands.deployment.api.Deployment.recreate")
def test_recreate(self, mock_recreate):
deployment_id = "43924f8b-9371-4152-af9f-4cf02b4eced4"
self.deployment.recreate(deployment_id)
mock_recreate.assert_called_once_with(deployment_id)
@mock.patch("rally.cmd.commands.deployment.envutils.get_global")
@mock.patch("rally.cli.commands.deployment.envutils.get_global")
def test_recreate_no_deployment_id(self, mock_default):
mock_default.side_effect = exceptions.InvalidArgumentsException
self.assertRaises(exceptions.InvalidArgumentsException,
self.deployment.recreate, None)
@mock.patch("rally.cmd.commands.deployment.api.Deployment.destroy")
@mock.patch("rally.cli.commands.deployment.api.Deployment.destroy")
def test_destroy(self, mock_destroy):
deployment_id = "53fd0273-60ce-42e5-a759-36f1a683103e"
self.deployment.destroy(deployment_id)
mock_destroy.assert_called_once_with(deployment_id)
@mock.patch("rally.cmd.commands.deployment.envutils.get_global")
@mock.patch("rally.cli.commands.deployment.envutils.get_global")
def test_destroy_no_deployment_id(self, mock_default):
mock_default.side_effect = exceptions.InvalidArgumentsException
self.assertRaises(exceptions.InvalidArgumentsException,
self.deployment.destroy, None)
@mock.patch("rally.cmd.commands.deployment.cliutils.print_list")
@mock.patch("rally.cmd.commands.deployment.utils.Struct")
@mock.patch("rally.cmd.commands.deployment.envutils.get_global")
@mock.patch("rally.cmd.commands.deployment.db.deployment_list")
@mock.patch("rally.cli.commands.deployment.cliutils.print_list")
@mock.patch("rally.cli.commands.deployment.utils.Struct")
@mock.patch("rally.cli.commands.deployment.envutils.get_global")
@mock.patch("rally.cli.commands.deployment.db.deployment_list")
def test_list_different_deployment_id(self, mock_deployments,
mock_default, mock_struct,
mock_print_list):
@ -133,10 +133,10 @@ class DeploymentCommandsTestCase(test.TestCase):
sortby_index=headers.index(
"created_at"))
@mock.patch("rally.cmd.commands.deployment.cliutils.print_list")
@mock.patch("rally.cmd.commands.deployment.utils.Struct")
@mock.patch("rally.cmd.commands.deployment.envutils.get_global")
@mock.patch("rally.cmd.commands.deployment.db.deployment_list")
@mock.patch("rally.cli.commands.deployment.cliutils.print_list")
@mock.patch("rally.cli.commands.deployment.utils.Struct")
@mock.patch("rally.cli.commands.deployment.envutils.get_global")
@mock.patch("rally.cli.commands.deployment.db.deployment_list")
def test_list_current_deployment_id(self, mock_deployments,
mock_default, mock_struct,
mock_print_list):
@ -159,7 +159,7 @@ class DeploymentCommandsTestCase(test.TestCase):
sortby_index=headers.index(
"created_at"))
@mock.patch("rally.cmd.commands.deployment.db.deployment_get")
@mock.patch("rally.cli.commands.deployment.db.deployment_get")
@mock.patch("json.dumps")
def test_config(self, mock_json_dumps, mock_deployment):
deployment_id = "fa4a423e-f15d-4d83-971a-89574f892999"
@ -170,15 +170,15 @@ class DeploymentCommandsTestCase(test.TestCase):
sort_keys=True, indent=4)
mock_deployment.assert_called_once_with(deployment_id)
@mock.patch("rally.cmd.commands.deployment.envutils.get_global")
@mock.patch("rally.cli.commands.deployment.envutils.get_global")
def test_config_no_deployment_id(self, mock_default):
mock_default.side_effect = exceptions.InvalidArgumentsException
self.assertRaises(exceptions.InvalidArgumentsException,
self.deployment.config, None)
@mock.patch("rally.cmd.commands.deployment.cliutils.print_list")
@mock.patch("rally.cmd.commands.deployment.utils.Struct")
@mock.patch("rally.cmd.commands.deployment.db.deployment_get")
@mock.patch("rally.cli.commands.deployment.cliutils.print_list")
@mock.patch("rally.cli.commands.deployment.utils.Struct")
@mock.patch("rally.cli.commands.deployment.db.deployment_get")
def test_show(self, mock_deployment, mock_struct, mock_print_list):
deployment_id = "b1a6153e-a314-4cb3-b63b-cf08c1a416c3"
value = {
@ -202,7 +202,7 @@ class DeploymentCommandsTestCase(test.TestCase):
mock_struct.assert_called_once_with(**dict(zip(headers, fake_data)))
mock_print_list.assert_called_once_with([mock_struct()], headers)
@mock.patch("rally.cmd.commands.deployment.envutils.get_global")
@mock.patch("rally.cli.commands.deployment.envutils.get_global")
def test_deploy_no_deployment_id(self, mock_default):
mock_default.side_effect = exceptions.InvalidArgumentsException
self.assertRaises(exceptions.InvalidArgumentsException,
@ -210,7 +210,7 @@ class DeploymentCommandsTestCase(test.TestCase):
@mock.patch("os.remove")
@mock.patch("os.symlink")
@mock.patch("rally.cmd.commands.deployment.db.deployment_get",
@mock.patch("rally.cli.commands.deployment.db.deployment_get",
return_value=fakes.FakeDeployment(
uuid="593b683c-4b16-4b2b-a56b-e162bd60f10b"))
@mock.patch("os.path.exists", return_value=True)
@ -227,7 +227,7 @@ class DeploymentCommandsTestCase(test.TestCase):
"endpoint": "fake_endpoint",
"region_name": None}
with mock.patch("rally.cmd.commands.deployment.open", mock.mock_open(),
with mock.patch("rally.cli.commands.deployment.open", mock.mock_open(),
create=True) as mock_file:
self.deployment.use(deployment_id)
self.assertEqual(2, mock_path.call_count)
@ -247,10 +247,10 @@ class DeploymentCommandsTestCase(test.TestCase):
mock_remove.assert_called_once_with(os.path.expanduser(
"~/.rally/openrc"))
@mock.patch("rally.cmd.commands.deployment.DeploymentCommands."
@mock.patch("rally.cli.commands.deployment.DeploymentCommands."
"_update_openrc_deployment_file")
@mock.patch("rally.common.fileutils.update_globals_file")
@mock.patch("rally.cmd.commands.deployment.db")
@mock.patch("rally.cli.commands.deployment.db")
def test_use_by_name(self, mock_db, mock_update_openrc,
mock_update_globals):
fake_deployment = fakes.FakeDeployment(
@ -266,7 +266,7 @@ class DeploymentCommandsTestCase(test.TestCase):
mock_update_globals.assert_called_once_with(
"fake_uuid", "fake_endpoints")
@mock.patch("rally.cmd.commands.deployment.db.deployment_get")
@mock.patch("rally.cli.commands.deployment.db.deployment_get")
def test_deployment_not_found(self, mock_deployment_get):
deployment_id = "e87e4dca-b515-4477-888d-5f6103f13b42"
mock_deployment_get.side_effect = exceptions.DeploymentNotFound(
@ -274,7 +274,7 @@ class DeploymentCommandsTestCase(test.TestCase):
self.assertEqual(1, self.deployment.use(deployment_id))
@mock.patch("rally.osclients.Clients.verified_keystone")
@mock.patch("rally.cmd.commands.deployment.db.deployment_get")
@mock.patch("rally.cli.commands.deployment.db.deployment_get")
def test_deployment_check(self, mock_deployment_get, mock_client):
deployment_id = "e87e4dca-b515-4477-888d-5f6103f13b42"
sample_endpoint = objects.Endpoint("http://192.168.1.1:5000/v2.0/",
@ -286,7 +286,7 @@ class DeploymentCommandsTestCase(test.TestCase):
self.deployment.check(deployment_id)
@mock.patch("rally.osclients.Clients.verified_keystone")
@mock.patch("rally.cmd.commands.deployment.db.deployment_get")
@mock.patch("rally.cli.commands.deployment.db.deployment_get")
def test_deployment_check_raise(self, mock_deployment_get, mock_client):
deployment_id = "e87e4dca-b515-4477-888d-5f6103f13b42"
sample_endpoint = objects.Endpoint("http://192.168.1.1:5000/v2.0/",

View File

@ -17,7 +17,7 @@ import mock
from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.sla import base as sla_base
from rally.cmd.commands import info
from rally.cli.commands import info
from rally import deploy
from rally.deploy.engines import existing as existing_cloud
from rally.deploy import serverprovider
@ -28,12 +28,12 @@ from rally.plugins.common.sla import failure_rate
from tests.unit import test
SCENARIO = "rally.cmd.commands.info.scenario_base.Scenario"
SLA = "rally.cmd.commands.info.sla_base.SLA"
ENGINE = "rally.cmd.commands.info.deploy.EngineFactory"
PROVIDER = "rally.cmd.commands.info.serverprovider.ProviderFactory"
UTILS = "rally.cmd.commands.info.utils"
COMMANDS = "rally.cmd.commands.info.InfoCommands"
SCENARIO = "rally.cli.commands.info.scenario_base.Scenario"
SLA = "rally.cli.commands.info.sla_base.SLA"
ENGINE = "rally.cli.commands.info.deploy.EngineFactory"
PROVIDER = "rally.cli.commands.info.serverprovider.ProviderFactory"
UTILS = "rally.cli.commands.info.utils"
COMMANDS = "rally.cli.commands.info.InfoCommands"
class InfoCommandsTestCase(test.TestCase):

View File

@ -15,7 +15,7 @@
import mock
from rally.cmd.commands import show
from rally.cli.commands import show
from tests.unit import fakes
from tests.unit import test
@ -43,12 +43,12 @@ class ShowCommandsTestCase(test.TestCase):
self.fake_glance_client = fakes.FakeGlanceClient()
self.fake_nova_client = fakes.FakeNovaClient()
@mock.patch("rally.cmd.commands.show.print", create=True)
@mock.patch("rally.cmd.commands.show.cliutils.print_list")
@mock.patch("rally.cmd.commands.show.cliutils.pretty_float_formatter")
@mock.patch("rally.cmd.commands.show.utils.Struct")
@mock.patch("rally.cmd.commands.show.osclients.Clients.glance")
@mock.patch("rally.cmd.commands.show.db.deployment_get")
@mock.patch("rally.cli.commands.show.print", create=True)
@mock.patch("rally.cli.commands.show.cliutils.print_list")
@mock.patch("rally.cli.commands.show.cliutils.pretty_float_formatter")
@mock.patch("rally.cli.commands.show.utils.Struct")
@mock.patch("rally.cli.commands.show.osclients.Clients.glance")
@mock.patch("rally.cli.commands.show.db.deployment_get")
def test_images(self, mock_deployment_get, mock_get_glance,
mock_struct, mock_formatter, mock_print_list, mock_print):
self.fake_glance_client.images.create("image", None, None, None)
@ -82,11 +82,11 @@ class ShowCommandsTestCase(test.TestCase):
)] * 3)
self.assertEqual(3, mock_print.call_count)
@mock.patch("rally.cmd.commands.show.cliutils.print_list")
@mock.patch("rally.cmd.commands.show.cliutils.pretty_float_formatter")
@mock.patch("rally.cmd.commands.show.utils.Struct")
@mock.patch("rally.cmd.commands.show.osclients.Clients.nova")
@mock.patch("rally.cmd.commands.show.db.deployment_get")
@mock.patch("rally.cli.commands.show.cliutils.print_list")
@mock.patch("rally.cli.commands.show.cliutils.pretty_float_formatter")
@mock.patch("rally.cli.commands.show.utils.Struct")
@mock.patch("rally.cli.commands.show.osclients.Clients.nova")
@mock.patch("rally.cli.commands.show.db.deployment_get")
def test_flavors(self, mock_deployment_get, mock_get_nova,
mock_struct, mock_formatter, mock_print_list):
self.fake_nova_client.flavors.create()
@ -123,10 +123,10 @@ class ShowCommandsTestCase(test.TestCase):
mixed_case_fields=mixed_case_fields
)] * 3)
@mock.patch("rally.cmd.commands.show.cliutils.print_list")
@mock.patch("rally.cmd.commands.show.utils.Struct")
@mock.patch("rally.cmd.commands.show.osclients.Clients.nova")
@mock.patch("rally.cmd.commands.show.db.deployment_get")
@mock.patch("rally.cli.commands.show.cliutils.print_list")
@mock.patch("rally.cli.commands.show.utils.Struct")
@mock.patch("rally.cli.commands.show.osclients.Clients.nova")
@mock.patch("rally.cli.commands.show.db.deployment_get")
def test_networks(self, mock_deployment_get, mock_get_nova,
mock_struct, mock_print_list):
self.fake_nova_client.networks.create(1234)
@ -157,10 +157,10 @@ class ShowCommandsTestCase(test.TestCase):
mixed_case_fields=mixed_case_fields
)] * 3)
@mock.patch("rally.cmd.commands.show.cliutils.print_list")
@mock.patch("rally.cmd.commands.show.utils.Struct")
@mock.patch("rally.cmd.commands.show.osclients.Clients.nova")
@mock.patch("rally.cmd.commands.show.db.deployment_get")
@mock.patch("rally.cli.commands.show.cliutils.print_list")
@mock.patch("rally.cli.commands.show.utils.Struct")
@mock.patch("rally.cli.commands.show.osclients.Clients.nova")
@mock.patch("rally.cli.commands.show.db.deployment_get")
def test_secgroups(self, mock_deployment_get, mock_get_nova,
mock_struct, mock_print_list):
self.fake_nova_client.security_groups.create("othersg")
@ -194,10 +194,10 @@ class ShowCommandsTestCase(test.TestCase):
mixed_case_fields=mixed_case_fields
)] * 2)
@mock.patch("rally.cmd.commands.show.cliutils.print_list")
@mock.patch("rally.cmd.commands.show.utils.Struct")
@mock.patch("rally.cmd.commands.show.osclients.Clients.nova")
@mock.patch("rally.cmd.commands.show.db.deployment_get")
@mock.patch("rally.cli.commands.show.cliutils.print_list")
@mock.patch("rally.cli.commands.show.utils.Struct")
@mock.patch("rally.cli.commands.show.osclients.Clients.nova")
@mock.patch("rally.cli.commands.show.db.deployment_get")
def test_keypairs(self, mock_deployment_get, mock_get_nova,
mock_struct, mock_print_list):
self.fake_nova_client.keypairs.create("keypair")

View File

@ -19,7 +19,7 @@ import os.path
import mock
from rally.cmd.commands import task
from rally.cli.commands import task
from rally import consts
from rally import exceptions
from tests.unit import fakes
@ -32,7 +32,7 @@ class TaskCommandsTestCase(test.TestCase):
super(TaskCommandsTestCase, self).setUp()
self.task = task.TaskCommands()
@mock.patch("rally.cmd.commands.task.open", create=True)
@mock.patch("rally.cli.commands.task.open", create=True)
def test_load_task(self, mock_open):
input_task = "{'ab': {{test}}}"
input_args = "{'test': 2}"
@ -61,7 +61,7 @@ class TaskCommandsTestCase(test.TestCase):
task_args_file="any_file")
self.assertEqual(result, {"ab": 2})
@mock.patch("rally.cmd.commands.task.open", create=True)
@mock.patch("rally.cli.commands.task.open", create=True)
def test_load_task_wrong_task_args_file(self, mock_open):
mock_open.side_effect = [
mock.mock_open(read_data="{'test': {}").return_value
@ -70,7 +70,7 @@ class TaskCommandsTestCase(test.TestCase):
self.task._load_task,
"in_task", task_args_file="in_args_path")
@mock.patch("rally.cmd.commands.task.open", create=True)
@mock.patch("rally.cli.commands.task.open", create=True)
def test_load_task_wrong_task_args_file_exception(self, mock_open):
mock_open.side_effect = IOError
self.assertRaises(IOError, self.task._load_task,
@ -82,7 +82,7 @@ class TaskCommandsTestCase(test.TestCase):
self.assertRaises(task.FailedToLoadTask,
self.task._load_task, "in_task", "[]")
@mock.patch("rally.cmd.commands.task.open", create=True)
@mock.patch("rally.cli.commands.task.open", create=True)
def test_load_task_task_render_raise_exc(self, mock_open):
mock_open.side_effect = [
mock.mock_open(read_data="{'test': {{t}}}").return_value
@ -90,7 +90,7 @@ class TaskCommandsTestCase(test.TestCase):
self.assertRaises(task.FailedToLoadTask,
self.task._load_task, "in_task")
@mock.patch("rally.cmd.commands.task.open", create=True)
@mock.patch("rally.cli.commands.task.open", create=True)
def test_load_task_task_not_in_yaml(self, mock_open):
mock_open.side_effect = [
mock.mock_open(read_data="{'test': {}").return_value
@ -98,11 +98,11 @@ class TaskCommandsTestCase(test.TestCase):
self.assertRaises(task.FailedToLoadTask,
self.task._load_task, "in_task")
@mock.patch("rally.cmd.commands.task.TaskCommands.detailed")
@mock.patch("rally.cmd.commands.task.TaskCommands._load_task",
@mock.patch("rally.cli.commands.task.TaskCommands.detailed")
@mock.patch("rally.cli.commands.task.TaskCommands._load_task",
return_value={"some": "json"})
@mock.patch("rally.api.Task.create")
@mock.patch("rally.cmd.commands.task.api.Task.start")
@mock.patch("rally.cli.commands.task.api.Task.start")
def test_start(self, mock_api, mock_create_task, mock_load,
mock_task_detailed):
mock_create_task.return_value = (
@ -117,7 +117,7 @@ class TaskCommandsTestCase(test.TestCase):
abort_on_sla_failure=False)
mock_load.assert_called_once_with(task_path, None, None)
@mock.patch("rally.cmd.commands.task.TaskCommands._load_task",
@mock.patch("rally.cli.commands.task.TaskCommands._load_task",
side_effect=task.FailedToLoadTask)
def test_start_with_task_args(self, mock_load):
task_path = mock.MagicMock()
@ -127,14 +127,14 @@ class TaskCommandsTestCase(test.TestCase):
task_args_file=task_args_file)
mock_load.assert_called_once_with(task_path, task_args, task_args_file)
@mock.patch("rally.cmd.commands.task.envutils.get_global")
@mock.patch("rally.cli.commands.task.envutils.get_global")
def test_start_no_deployment_id(self, mock_default):
mock_default.side_effect = exceptions.InvalidArgumentsException
self.assertRaises(exceptions.InvalidArgumentsException,
self.task.start, "path_to_config.json", None)
@mock.patch("rally.cmd.commands.task.TaskCommands._load_task")
@mock.patch("rally.cmd.commands.task.api")
@mock.patch("rally.cli.commands.task.TaskCommands._load_task")
@mock.patch("rally.cli.commands.task.api")
def test_start_invalid_task(self, mock_api, mock_load):
mock_api.Task.start.side_effect = exceptions.InvalidConfigException
@ -146,14 +146,14 @@ class TaskCommandsTestCase(test.TestCase):
"deployment", mock_load.return_value,
task=mock_api.Task.create.return_value, abort_on_sla_failure=False)
@mock.patch("rally.cmd.commands.task.api")
@mock.patch("rally.cli.commands.task.api")
def test_abort(self, mock_api):
test_uuid = "17860c43-2274-498d-8669-448eff7b073f"
mock_api.Task.abort = mock.MagicMock()
self.task.abort(test_uuid)
task.api.Task.abort.assert_called_once_with(test_uuid)
@mock.patch("rally.cmd.commands.task.envutils.get_global")
@mock.patch("rally.cli.commands.task.envutils.get_global")
def test_abort_no_task_id(self, mock_default):
mock_default.side_effect = exceptions.InvalidArgumentsException
self.assertRaises(exceptions.InvalidArgumentsException,
@ -162,18 +162,18 @@ class TaskCommandsTestCase(test.TestCase):
def test_status(self):
test_uuid = "a3e7cefb-bec2-4802-89f6-410cc31f71af"
value = {"task_id": "task", "status": "status"}
with mock.patch("rally.cmd.commands.task.db") as mock_db:
with mock.patch("rally.cli.commands.task.db") as mock_db:
mock_db.task_get = mock.MagicMock(return_value=value)
self.task.status(test_uuid)
mock_db.task_get.assert_called_once_with(test_uuid)
@mock.patch("rally.cmd.commands.task.envutils.get_global")
@mock.patch("rally.cli.commands.task.envutils.get_global")
def test_status_no_task_id(self, mock_default):
mock_default.side_effect = exceptions.InvalidArgumentsException
self.assertRaises(exceptions.InvalidArgumentsException,
self.task.status, None)
@mock.patch("rally.cmd.commands.task.db")
@mock.patch("rally.cli.commands.task.db")
def test_detailed(self, mock_db):
test_uuid = "c0d874d4-7195-4fd5-8688-abe82bfad36f"
value = {
@ -247,8 +247,8 @@ class TaskCommandsTestCase(test.TestCase):
self.task.detailed(test_uuid, iterations_data=True)
@mock.patch("rally.cmd.commands.task.db")
@mock.patch("rally.cmd.commands.task.logging")
@mock.patch("rally.cli.commands.task.db")
@mock.patch("rally.cli.commands.task.logging")
def test_detailed_task_failed(self, mock_logging, mock_db):
value = {
"id": "task",
@ -265,13 +265,13 @@ class TaskCommandsTestCase(test.TestCase):
mock_logging.is_debug.return_value = True
self.task.detailed("task_uuid")
@mock.patch("rally.cmd.commands.task.envutils.get_global")
@mock.patch("rally.cli.commands.task.envutils.get_global")
def test_detailed_no_task_id(self, mock_default):
mock_default.side_effect = exceptions.InvalidArgumentsException
self.assertRaises(exceptions.InvalidArgumentsException,
self.task.detailed, None)
@mock.patch("rally.cmd.commands.task.db")
@mock.patch("rally.cli.commands.task.db")
def test_detailed_wrong_id(self, mock_db):
test_uuid = "eb290c30-38d8-4c8f-bbcc-fc8f74b004ae"
mock_db.task_get_detailed = mock.MagicMock(return_value=None)
@ -279,7 +279,7 @@ class TaskCommandsTestCase(test.TestCase):
mock_db.task_get_detailed.assert_called_once_with(test_uuid)
@mock.patch("json.dumps")
@mock.patch("rally.cmd.commands.task.objects.Task.get")
@mock.patch("rally.cli.commands.task.objects.Task.get")
def test_results(self, mock_get, mock_json):
task_id = "foo_task_id"
data = [
@ -303,8 +303,8 @@ class TaskCommandsTestCase(test.TestCase):
mock_json.call_args[1])
mock_get.assert_called_once_with(task_id)
@mock.patch("rally.cmd.commands.task.sys.stdout")
@mock.patch("rally.cmd.commands.task.objects.Task.get")
@mock.patch("rally.cli.commands.task.sys.stdout")
@mock.patch("rally.cli.commands.task.objects.Task.get")
def test_results_no_data(self, mock_get, mock_stdout):
task_id = "foo_task_id"
mock_results = mock.Mock(return_value=[])
@ -317,15 +317,15 @@ class TaskCommandsTestCase(test.TestCase):
" available when it is finished." % task_id)
mock_stdout.write.assert_has_calls([mock.call(expected_out)])
@mock.patch("rally.cmd.commands.task.jsonschema.validate",
@mock.patch("rally.cli.commands.task.jsonschema.validate",
return_value=None)
@mock.patch("rally.cmd.commands.task.os.path.realpath",
@mock.patch("rally.cli.commands.task.os.path.realpath",
side_effect=lambda p: "realpath_%s" % p)
@mock.patch("rally.cmd.commands.task.open",
@mock.patch("rally.cli.commands.task.open",
side_effect=mock.mock_open(), create=True)
@mock.patch("rally.cmd.commands.task.plot")
@mock.patch("rally.cmd.commands.task.webbrowser")
@mock.patch("rally.cmd.commands.task.objects.Task.get")
@mock.patch("rally.cli.commands.task.plot")
@mock.patch("rally.cli.commands.task.webbrowser")
@mock.patch("rally.cli.commands.task.objects.Task.get")
def test_report_one_uuid(self, mock_get, mock_web, mock_plot, mock_open,
mock_os, mock_validate):
task_id = "eb290c30-38d8-4c8f-bbcc-fc8f74b004ae"
@ -364,15 +364,15 @@ class TaskCommandsTestCase(test.TestCase):
mock_web.open_new_tab.assert_called_once_with(
"file://realpath_spam.html")
@mock.patch("rally.cmd.commands.task.jsonschema.validate",
@mock.patch("rally.cli.commands.task.jsonschema.validate",
return_value=None)
@mock.patch("rally.cmd.commands.task.os.path.realpath",
@mock.patch("rally.cli.commands.task.os.path.realpath",
side_effect=lambda p: "realpath_%s" % p)
@mock.patch("rally.cmd.commands.task.open",
@mock.patch("rally.cli.commands.task.open",
side_effect=mock.mock_open(), create=True)
@mock.patch("rally.cmd.commands.task.plot")
@mock.patch("rally.cmd.commands.task.webbrowser")
@mock.patch("rally.cmd.commands.task.objects.Task.get")
@mock.patch("rally.cli.commands.task.plot")
@mock.patch("rally.cli.commands.task.webbrowser")
@mock.patch("rally.cli.commands.task.objects.Task.get")
def test_report_bunch_uuids(self, mock_get, mock_web, mock_plot, mock_open,
mock_os, mock_validate):
tasks = ["eb290c30-38d8-4c8f-bbcc-fc8f74b004ae",
@ -412,14 +412,14 @@ class TaskCommandsTestCase(test.TestCase):
expected_get_calls = [mock.call(task) for task in tasks]
mock_get.assert_has_calls(expected_get_calls, any_order=True)
@mock.patch("rally.cmd.commands.task.json.load")
@mock.patch("rally.cmd.commands.task.os.path.exists", return_value=True)
@mock.patch("rally.cmd.commands.task.jsonschema.validate",
@mock.patch("rally.cli.commands.task.json.load")
@mock.patch("rally.cli.commands.task.os.path.exists", return_value=True)
@mock.patch("rally.cli.commands.task.jsonschema.validate",
return_value=None)
@mock.patch("rally.cmd.commands.task.os.path.realpath",
@mock.patch("rally.cli.commands.task.os.path.realpath",
side_effect=lambda p: "realpath_%s" % p)
@mock.patch("rally.cmd.commands.task.open", create=True)
@mock.patch("rally.cmd.commands.task.plot")
@mock.patch("rally.cli.commands.task.open", create=True)
@mock.patch("rally.cli.commands.task.plot")
def test_report_one_file(self, mock_plot, mock_open, mock_os,
mock_validate, mock_path_exists, mock_json_load):
@ -457,9 +457,9 @@ class TaskCommandsTestCase(test.TestCase):
mock_open.side_effect().write.assert_called_once_with("html_report")
@mock.patch("rally.cmd.commands.task.os.path.exists", return_value=True)
@mock.patch("rally.cmd.commands.task.json.load")
@mock.patch("rally.cmd.commands.task.open", create=True)
@mock.patch("rally.cli.commands.task.os.path.exists", return_value=True)
@mock.patch("rally.cli.commands.task.json.load")
@mock.patch("rally.cli.commands.task.open", create=True)
def test_report_exceptions(self, mock_open, mock_json_load,
mock_path_exists):
@ -483,10 +483,10 @@ class TaskCommandsTestCase(test.TestCase):
out="/tmp/tmp.hsml")
self.assertEqual(ret, 1)
@mock.patch("rally.cmd.commands.task.cliutils.print_list")
@mock.patch("rally.cmd.commands.task.envutils.get_global",
@mock.patch("rally.cli.commands.task.cliutils.print_list")
@mock.patch("rally.cli.commands.task.envutils.get_global",
return_value="123456789")
@mock.patch("rally.cmd.commands.task.objects.Task.list",
@mock.patch("rally.cli.commands.task.objects.Task.list",
return_value=[fakes.FakeTask(uuid="a",
created_at=date.datetime.now(),
updated_at=date.datetime.now(),
@ -507,10 +507,10 @@ class TaskCommandsTestCase(test.TestCase):
mock_objects_list.return_value, headers,
sortby_index=headers.index("created_at"))
@mock.patch("rally.cmd.commands.task.cliutils.print_list")
@mock.patch("rally.cmd.commands.task.envutils.get_global",
@mock.patch("rally.cli.commands.task.cliutils.print_list")
@mock.patch("rally.cli.commands.task.envutils.get_global",
return_value="123456789")
@mock.patch("rally.cmd.commands.task.objects.Task.list",
@mock.patch("rally.cli.commands.task.objects.Task.list",
return_value=[fakes.FakeTask(uuid="a",
created_at=date.datetime.now(),
updated_at=date.datetime.now(),
@ -531,7 +531,7 @@ class TaskCommandsTestCase(test.TestCase):
self.assertEqual(1, self.task.list(deployment="fake",
status="wrong non existing status"))
@mock.patch("rally.cmd.commands.task.objects.Task.list", return_value=[])
@mock.patch("rally.cli.commands.task.objects.Task.list", return_value=[])
def test_list_no_results(self, mock_list):
self.assertIsNone(
self.task.list(deployment="fake", all_deployments=True))
@ -547,13 +547,13 @@ class TaskCommandsTestCase(test.TestCase):
def test_delete(self):
task_uuid = "8dcb9c5e-d60b-4022-8975-b5987c7833f7"
force = False
with mock.patch("rally.cmd.commands.task.api") as mock_api:
with mock.patch("rally.cli.commands.task.api") as mock_api:
mock_api.Task.delete = mock.Mock()
self.task.delete(task_uuid, force=force)
mock_api.Task.delete.assert_called_once_with(task_uuid,
force=force)
@mock.patch("rally.cmd.commands.task.api")
@mock.patch("rally.cli.commands.task.api")
def test_delete_multiple_uuid(self, mock_api):
task_uuids = ["4bf35b06-5916-484f-9547-12dce94902b7",
"52cad69d-d3e4-47e1-b445-dec9c5858fe8",
@ -566,8 +566,8 @@ class TaskCommandsTestCase(test.TestCase):
in task_uuids]
self.assertTrue(mock_api.Task.delete.mock_calls == expected_calls)
@mock.patch("rally.cmd.commands.task.cliutils.print_list")
@mock.patch("rally.cmd.commands.task.objects.Task.get")
@mock.patch("rally.cli.commands.task.cliutils.print_list")
@mock.patch("rally.cli.commands.task.objects.Task.get")
def test_sla_check(self, mock_task_get, mock_print_list):
data = [{"key": {"name": "fake_name",
"pos": "fake_pos",
@ -591,7 +591,7 @@ class TaskCommandsTestCase(test.TestCase):
result = self.task.sla_check(task_id="fake_task_id", tojson=True)
self.assertEqual(0, result)
@mock.patch("rally.cmd.commands.task.open",
@mock.patch("rally.cli.commands.task.open",
mock.mock_open(read_data="{\"some\": \"json\"}"),
create=True)
@mock.patch("rally.api.Task.validate")
@ -599,7 +599,7 @@ class TaskCommandsTestCase(test.TestCase):
self.task.validate("path_to_config.json", "fake_id")
mock_validate.assert_called_once_with("fake_id", {"some": "json"})
@mock.patch("rally.cmd.commands.task.TaskCommands._load_task",
@mock.patch("rally.cli.commands.task.TaskCommands._load_task",
side_effect=task.FailedToLoadTask)
def test_validate_failed_to_load_task(self, mock_load):
args = mock.MagicMock()
@ -610,7 +610,7 @@ class TaskCommandsTestCase(test.TestCase):
self.assertEqual(1, result)
mock_load.assert_called_once_with("path_to_task", args, args_file)
@mock.patch("rally.cmd.commands.task.TaskCommands._load_task")
@mock.patch("rally.cli.commands.task.TaskCommands._load_task")
@mock.patch("rally.api.Task.validate")
def test_validate_invalid(self, mock_task_validate, mock_load):
@ -621,7 +621,7 @@ class TaskCommandsTestCase(test.TestCase):
mock_load.return_value)
@mock.patch("rally.common.fileutils._rewrite_env_file")
@mock.patch("rally.cmd.commands.task.db.task_get", return_value=True)
@mock.patch("rally.cli.commands.task.db.task_get", return_value=True)
def test_use(self, mock_task, mock_file):
task_id = "80422553-5774-44bd-98ac-38bd8c7a0feb"
self.task.use(task_id)
@ -629,7 +629,7 @@ class TaskCommandsTestCase(test.TestCase):
os.path.expanduser("~/.rally/globals"),
["RALLY_TASK=%s\n" % task_id])
@mock.patch("rally.cmd.commands.task.db.task_get")
@mock.patch("rally.cli.commands.task.db.task_get")
def test_use_not_found(self, mock_task):
task_id = "ddc3f8ba-082a-496d-b18f-72cdf5c10a14"
mock_task.side_effect = exceptions.TaskNotFound(uuid=task_id)

View File

@ -15,10 +15,10 @@
import mock
from rally.cmd.commands import use
from rally.cli.commands import use
from tests.unit import test
MOD = "rally.cmd.commands.use."
MOD = "rally.cli.commands.use."
class UseCommandsTestCase(test.TestCase):
@ -26,17 +26,17 @@ class UseCommandsTestCase(test.TestCase):
super(UseCommandsTestCase, self).setUp()
self.use = use.UseCommands()
@mock.patch("rally.cmd.commands.deployment.DeploymentCommands.use")
@mock.patch("rally.cli.commands.deployment.DeploymentCommands.use")
def test_deployment(self, mock_deployment_use):
self.use.deployment("fake_id")
mock_deployment_use.assert_called_once_with("fake_id")
@mock.patch("rally.cmd.commands.task.TaskCommands.use")
@mock.patch("rally.cli.commands.task.TaskCommands.use")
def test_task(self, mock_task_use):
self.use.task("fake_id")
mock_task_use.assert_called_once_with("fake_id")
@mock.patch("rally.cmd.commands.verify.VerifyCommands.use")
@mock.patch("rally.cli.commands.verify.VerifyCommands.use")
def test_verification(self, mock_verify_use):
self.use.verification("fake_id")
mock_verify_use.assert_called_once_with("fake_id")

View File

@ -20,7 +20,7 @@ import tempfile
import mock
import six
from rally.cmd.commands import verify
from rally.cli.commands import verify
from rally import consts
from rally import exceptions
from rally import objects
@ -95,7 +95,7 @@ class VerifyCommandsTestCase(test.TestCase):
consts.TempestTestsAPI)
self.assertFalse(mock_verify.called)
@mock.patch("rally.cmd.cliutils.print_list")
@mock.patch("rally.cli.cliutils.print_list")
@mock.patch("rally.db.verification_list")
def test_list(self, mock_db_verification_list, mock_print_list):
fields = ["UUID", "Deployment UUID", "Set name", "Tests", "Failures",
@ -114,7 +114,7 @@ class VerifyCommandsTestCase(test.TestCase):
sortby_index=fields.index(
"Created at"))
@mock.patch("rally.cmd.cliutils.print_list")
@mock.patch("rally.cli.cliutils.print_list")
@mock.patch("rally.db.verification_get")
@mock.patch("rally.db.verification_result_get")
@mock.patch("rally.objects.Verification")
@ -168,7 +168,7 @@ class VerifyCommandsTestCase(test.TestCase):
mock_db_result_get.assert_called_once_with(verification_uuid)
@mock.patch("rally.cmd.commands.verify.open",
@mock.patch("rally.cli.commands.verify.open",
side_effect=mock.mock_open(), create=True)
@mock.patch("rally.db.verification_result_get", return_value={"data": {}})
def test_results_with_output_json_and_output_file(self,
@ -183,7 +183,7 @@ class VerifyCommandsTestCase(test.TestCase):
mock_open.assert_called_once_with("results", "wb")
mock_open.side_effect().write.assert_called_once_with("{}")
@mock.patch("rally.cmd.commands.verify.open",
@mock.patch("rally.cli.commands.verify.open",
side_effect=mock.mock_open(), create=True)
@mock.patch("rally.db.verification_result_get")
@mock.patch("rally.verification.tempest.json2html.HtmlOutput")
@ -234,7 +234,7 @@ class VerifyCommandsTestCase(test.TestCase):
mock_db_result_get.assert_called_once_with(uuid1)
@mock.patch("rally.cmd.commands.verify.open",
@mock.patch("rally.cli.commands.verify.open",
side_effect=mock.mock_open(), create=True)
@mock.patch("rally.db.verification_result_get",
return_value={"data": {"test_cases": {}}})
@ -255,7 +255,7 @@ class VerifyCommandsTestCase(test.TestCase):
mock_open.assert_called_once_with("results", "wb")
mock_open.side_effect().write.assert_called_once_with(fake_string)
@mock.patch("rally.cmd.commands.verify.open",
@mock.patch("rally.cli.commands.verify.open",
side_effect=mock.mock_open(), create=True)
@mock.patch("rally.db.verification_result_get",
return_value={"data": {"test_cases": {}}})
@ -275,7 +275,7 @@ class VerifyCommandsTestCase(test.TestCase):
mock_open.assert_called_once_with("results", "wb")
mock_open.side_effect().write.assert_called_once_with(fake_json_string)
@mock.patch("rally.cmd.commands.verify.open",
@mock.patch("rally.cli.commands.verify.open",
side_effect=mock.mock_open(), create=True)
@mock.patch("rally.db.verification_result_get")
@mock.patch(("rally.verification.tempest."
@ -303,7 +303,7 @@ class VerifyCommandsTestCase(test.TestCase):
mock_open.side_effect().write.assert_called_once_with("")
@mock.patch("rally.common.fileutils._rewrite_env_file")
@mock.patch("rally.cmd.commands.verify.db.verification_get",
@mock.patch("rally.cli.commands.verify.db.verification_get",
return_value=True)
def test_use(self, mock_task, mock_file):
verification_id = "80422553-5774-44bd-98ac-38bd8c7a0feb"
@ -312,7 +312,7 @@ class VerifyCommandsTestCase(test.TestCase):
os.path.expanduser("~/.rally/globals"),
["RALLY_VERIFICATION=%s\n" % verification_id])
@mock.patch("rally.cmd.commands.verify.db.verification_get")
@mock.patch("rally.cli.commands.verify.db.verification_get")
def test_use_not_found(self, mock_verification_get):
verification_id = "ddc3f8ba-082a-496d-b18f-72cdf5c10a14"
mock_verification_get.side_effect = exceptions.NotFoundException(

View File

@ -18,13 +18,13 @@ import mock
from oslo_config import cfg
from six import moves
from rally.cmd import cliutils
from rally.cmd.commands import deployment
from rally.cmd.commands import info
from rally.cmd.commands import show
from rally.cmd.commands import task
from rally.cmd.commands import use
from rally.cmd.commands import verify
from rally.cli import cliutils
from rally.cli.commands import deployment
from rally.cli.commands import info
from rally.cli.commands import show
from rally.cli.commands import task
from rally.cli.commands import use
from rally.cli.commands import verify
from rally import exceptions
from tests.unit import test
@ -158,7 +158,7 @@ class CliUtilsTestCase(test.TestCase):
)
CONF.unregister_opt(category_opt)
@mock.patch("rally.cmd.cliutils.CONF", config_file=None,
@mock.patch("rally.cli.cliutils.CONF", config_file=None,
side_effect=cfg.ConfigFilesNotFoundError("config_file"))
def test_run_fails(self, mock_cmd_cliutils_conf):
ret = cliutils.run(["rally", "show", "flavors"], self.categories)
@ -189,7 +189,7 @@ class CliUtilsTestCase(test.TestCase):
self.assertTrue(mock_task_get.called)
self.assertEqual(ret, 1)
@mock.patch("rally.cmd.cliutils.validate_args",
@mock.patch("rally.cli.cliutils.validate_args",
side_effect=cliutils.MissingArgs("missing"))
def test_run_show_fails(self, mock_validate_args):
ret = cliutils.run(["rally", "show", "keypairs"], self.categories)

View File

@ -18,7 +18,7 @@ import os
import mock
from six import moves
from rally.cmd import envutils
from rally.cli import envutils
from rally import exceptions
from tests.unit import test
@ -47,7 +47,7 @@ class EnvUtilsTestCase(test.TestCase):
self.assertEqual("my_deployment_id", deployment_id)
@mock.patch.dict(os.environ, values={}, clear=True)
@mock.patch("rally.cmd.envutils.fileutils.load_env_file")
@mock.patch("rally.cli.envutils.fileutils.load_env_file")
def test_get_deployment_id_with_exception(self, mock_file):
self.assertRaises(exceptions.InvalidArgumentsException,
envutils.get_global, envutils.ENV_DEPLOYMENT, True)
@ -55,7 +55,7 @@ class EnvUtilsTestCase(test.TestCase):
"~/.rally/globals"))
@mock.patch.dict(os.environ, values={}, clear=True)
@mock.patch("rally.cmd.envutils.fileutils.load_env_file")
@mock.patch("rally.cli.envutils.fileutils.load_env_file")
def test_get_deployment_id_with_none(self, mock_file):
self.assertIsNone(envutils.get_global(envutils.ENV_DEPLOYMENT))
mock_file.assert_called_once_with(os.path.expanduser(
@ -67,7 +67,7 @@ class EnvUtilsTestCase(test.TestCase):
self.assertEqual("my_task_id", envutils.get_global(envutils.ENV_TASK))
@mock.patch.dict(os.environ, values={}, clear=True)
@mock.patch("rally.cmd.envutils.fileutils.load_env_file")
@mock.patch("rally.cli.envutils.fileutils.load_env_file")
def test_get_task_id_with_exception(self, mock_file):
self.assertRaises(exceptions.InvalidArgumentsException,
envutils.get_global, envutils.ENV_TASK, True)
@ -75,7 +75,7 @@ class EnvUtilsTestCase(test.TestCase):
"~/.rally/globals"))
@mock.patch.dict(os.environ, values={}, clear=True)
@mock.patch("rally.cmd.envutils.fileutils.load_env_file")
@mock.patch("rally.cli.envutils.fileutils.load_env_file")
def test_get_task_id_with_none(self, mock_file):
self.assertIsNone(envutils.get_global("RALLY_TASK"))
mock_file.assert_called_once_with(os.path.expanduser(
@ -85,7 +85,7 @@ class EnvUtilsTestCase(test.TestCase):
values={envutils.ENV_DEPLOYMENT: "test_deployment_id"},
clear=True)
@mock.patch("os.path.exists")
@mock.patch("rally.cmd.envutils.fileutils.update_env_file",
@mock.patch("rally.cli.envutils.fileutils.update_env_file",
return_value=True)
def test_clear_global(self, mock_file, mock_file_status):
envutils.clear_global(envutils.ENV_DEPLOYMENT)
@ -98,7 +98,7 @@ class EnvUtilsTestCase(test.TestCase):
envutils.ENV_TASK: "test_task_id"},
clear=True)
@mock.patch("os.path.exists")
@mock.patch("rally.cmd.envutils.fileutils.update_env_file",
@mock.patch("rally.cli.envutils.fileutils.update_env_file",
return_value=True)
def test_clear_env(self, mock_file, mock_file_status):
envutils.clear_env()

View File

@ -17,13 +17,13 @@ import sys
import mock
from rally.cmd import manage
from rally.cli import manage
from tests.unit import test
class CmdManageTestCase(test.TestCase):
@mock.patch("rally.cmd.manage.cliutils")
@mock.patch("rally.cli.manage.cliutils")
def test_main(self, cli_mock):
manage.main()
categories = {"db": manage.DBCommands,
@ -37,7 +37,7 @@ class DBCommandsTestCase(test.TestCase):
super(DBCommandsTestCase, self).setUp()
self.db_commands = manage.DBCommands()
@mock.patch("rally.cmd.manage.db")
@mock.patch("rally.cli.manage.db")
def test_recreate(self, mock_db):
self.db_commands.recreate()
calls = [mock.call.db_drop(), mock.call.db_create()]
@ -51,7 +51,7 @@ class TempestCommandsTestCase(test.TestCase):
self.tempest_commands = manage.TempestCommands()
self.tempest = mock.Mock()
@mock.patch("rally.cmd.manage.api")
@mock.patch("rally.cli.manage.api")
def test_install(self, mock_api):
deployment_uuid = "deployment_uuid"
self.tempest_commands.install(deployment_uuid)

View File

@ -19,7 +19,7 @@ import os
from oslo_utils import encodeutils
import rally
from rally.cmd import cliutils
from rally.cli import cliutils
from tests.unit import test
RES_PATH = os.path.join(os.path.dirname(rally.__file__), os.pardir, "etc")