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:
parent
4e7bea0c68
commit
54350da689
@ -25,8 +25,8 @@ packages =
|
|||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
rally = rally.cmd.main:main
|
rally = rally.cli.main:main
|
||||||
rally-manage = rally.cmd.manage:main
|
rally-manage = rally.cli.manage:main
|
||||||
oslo.config.opts =
|
oslo.config.opts =
|
||||||
rally = rally.common.opts:list_opts
|
rally = rally.common.opts:list_opts
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import unittest
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.cmd import envutils
|
from rally.cli import envutils
|
||||||
from tests.functional import utils
|
from tests.functional import utils
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class DeploymentTestCase(unittest.TestCase):
|
|||||||
def test_check_fail(self):
|
def test_check_fail(self):
|
||||||
with mock.patch.dict("os.environ", utils.TEST_ENV):
|
with mock.patch.dict("os.environ", utils.TEST_ENV):
|
||||||
self.rally("deployment create --name t_create_env --fromenv")
|
self.rally("deployment create --name t_create_env --fromenv")
|
||||||
self.assertRaises(utils.RallyCmdError, self.rally,
|
self.assertRaises(utils.RallyCliError, self.rally,
|
||||||
("deployment check"))
|
("deployment check"))
|
||||||
|
|
||||||
def test_recreate(self):
|
def test_recreate(self):
|
||||||
|
@ -20,7 +20,7 @@ import unittest
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.cmd import envutils
|
from rally.cli import envutils
|
||||||
from tests.functional import utils
|
from tests.functional import utils
|
||||||
|
|
||||||
|
|
||||||
@ -95,37 +95,37 @@ class TaskTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_results_with_wrong_task_id(self):
|
def test_results_with_wrong_task_id(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task results --uuid %s" % FAKE_TASK_UUID)
|
rally, "task results --uuid %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_abort_with_wrong_task_id(self):
|
def test_abort_with_wrong_task_id(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task abort --uuid %s" % FAKE_TASK_UUID)
|
rally, "task abort --uuid %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_delete_with_wrong_task_id(self):
|
def test_delete_with_wrong_task_id(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task delete --uuid %s" % FAKE_TASK_UUID)
|
rally, "task delete --uuid %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_detailed_with_wrong_task_id(self):
|
def test_detailed_with_wrong_task_id(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task detailed --uuid %s" % FAKE_TASK_UUID)
|
rally, "task detailed --uuid %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_report_with_wrong_task_id(self):
|
def test_report_with_wrong_task_id(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task report --tasks %s" % FAKE_TASK_UUID)
|
rally, "task report --tasks %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_sla_check_with_wrong_task_id(self):
|
def test_sla_check_with_wrong_task_id(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task sla_check --uuid %s" % FAKE_TASK_UUID)
|
rally, "task sla_check --uuid %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_status_with_wrong_task_id(self):
|
def test_status_with_wrong_task_id(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task status --uuid %s" % FAKE_TASK_UUID)
|
rally, "task status --uuid %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_report_one_uuid(self):
|
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"))
|
rally("task report --out %s" % rally.gen_report_path(extension="html"))
|
||||||
self.assertTrue(os.path.exists(
|
self.assertTrue(os.path.exists(
|
||||||
rally.gen_report_path(extension="html")))
|
rally.gen_report_path(extension="html")))
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task report --report %s" % FAKE_TASK_UUID)
|
rally, "task report --report %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_report_bunch_uuids(self):
|
def test_report_bunch_uuids(self):
|
||||||
@ -196,7 +196,7 @@ class TaskTestCase(unittest.TestCase):
|
|||||||
rally.gen_report_path(extension="html")))
|
rally.gen_report_path(extension="html")))
|
||||||
self.assertTrue(os.path.exists(
|
self.assertTrue(os.path.exists(
|
||||||
rally.gen_report_path(extension="html")))
|
rally.gen_report_path(extension="html")))
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task report --report %s" % FAKE_TASK_UUID)
|
rally, "task report --report %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
@ -228,7 +228,7 @@ class TaskTestCase(unittest.TestCase):
|
|||||||
self.assertIn(
|
self.assertIn(
|
||||||
"deployment_name", rally("task list --all-deployments"))
|
"deployment_name", rally("task list --all-deployments"))
|
||||||
|
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task list --status not_existing_status")
|
rally, "task list --status not_existing_status")
|
||||||
|
|
||||||
def test_list_with_print_uuids_option(self):
|
def test_list_with_print_uuids_option(self):
|
||||||
@ -274,7 +274,7 @@ class TaskTestCase(unittest.TestCase):
|
|||||||
deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
|
deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
|
||||||
cfg = {"invalid": "config"}
|
cfg = {"invalid": "config"}
|
||||||
config = utils.TaskConfig(cfg)
|
config = utils.TaskConfig(cfg)
|
||||||
self.assertRaises(utils.RallyCmdError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally,
|
rally,
|
||||||
("task validate --task %(task_file)s "
|
("task validate --task %(task_file)s "
|
||||||
"--deployment %(deployment_id)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)
|
cfg = self._get_sample_task_config(max_seconds_per_iteration=0.001)
|
||||||
config = utils.TaskConfig(cfg)
|
config = utils.TaskConfig(cfg)
|
||||||
rally("task start --task %s" % config.filename)
|
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):
|
def test_sla_success(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
@ -609,7 +609,7 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
rally("task sla_check --json", getjson=True)
|
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)
|
self.assertEqual(json.loads(expected_error.output), expected)
|
||||||
else:
|
else:
|
||||||
self.fail("`rally task sla_check` command should return non-zero "
|
self.fail("`rally task sla_check` command should return non-zero "
|
||||||
@ -637,7 +637,7 @@ class SLAExtraFlagsTestCase(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
rally("task sla_check --json", getjson=True)
|
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)
|
self.assertEqual(json.loads(expected_error.output), expected)
|
||||||
else:
|
else:
|
||||||
self.fail("`rally task sla_check` command should return non-zero "
|
self.fail("`rally task sla_check` command should return non-zero "
|
||||||
|
@ -34,7 +34,7 @@ TEST_ENV = {
|
|||||||
DEPLOYMENT_FILE = "/tmp/rally_functests_main_deployment.json"
|
DEPLOYMENT_FILE = "/tmp/rally_functests_main_deployment.json"
|
||||||
|
|
||||||
|
|
||||||
class RallyCmdError(Exception):
|
class RallyCliError(Exception):
|
||||||
|
|
||||||
def __init__(self, code, output):
|
def __init__(self, code, output):
|
||||||
self.code = code
|
self.code = code
|
||||||
@ -184,4 +184,4 @@ class Rally(object):
|
|||||||
return json.loads(output)
|
return json.loads(output)
|
||||||
return output
|
return output
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
raise RallyCmdError(e.returncode, e.output)
|
raise RallyCliError(e.returncode, e.output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user