From 92ef11be17b60133523d2e95286c8fd7a784ed63 Mon Sep 17 00:00:00 2001 From: Olga Kopylova Date: Wed, 28 Jan 2015 11:15:42 +0200 Subject: [PATCH] Add aliases "rally task|deployment|verify use" Add alias "rally task use" for "rally use task", "rally deployment use" for "rally use deployment" and "rally verify use" for "rally use verification" Change-Id: I6e63f4b60e1faf794f050f98be127744fe8011a4 --- tests/functional/test_cli_deployment.py | 13 +++++++++++++ tests/functional/test_cli_task.py | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/functional/test_cli_deployment.py b/tests/functional/test_cli_deployment.py index 98f55b01..08b03be1 100644 --- a/tests/functional/test_cli_deployment.py +++ b/tests/functional/test_cli_deployment.py @@ -14,10 +14,12 @@ # under the License. import json +import re import unittest import mock +from rally.cmd import envutils from tests.functional import utils @@ -77,3 +79,14 @@ class DeploymentTestCase(unittest.TestCase): self.rally("deployment create --name t_create_env --fromenv") self.rally("deployment recreate --deployment t_create_env") self.assertIn("t_create_env", self.rally("deployment list")) + + def test_use(self): + with mock.patch.dict("os.environ", utils.TEST_ENV): + output = self.rally( + "deployment create --name t_create_env1 --fromenv") + uuid = re.search(r"Using deployment: (?P[0-9a-f\-]{36})", + output).group("uuid") + 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) \ No newline at end of file diff --git a/tests/functional/test_cli_task.py b/tests/functional/test_cli_task.py index 81db910d..9f873d98 100644 --- a/tests/functional/test_cli_task.py +++ b/tests/functional/test_cli_task.py @@ -247,6 +247,22 @@ class TaskTestCase(unittest.TestCase): def test_abort(self): pass + def test_use(self): + rally = utils.Rally() + with mock.patch.dict("os.environ", utils.TEST_ENV): + deployment_id = envutils.get_global("RALLY_DEPLOYMENT") + config = utils.TaskConfig(self._get_sample_task_config()) + output = rally(("task start --task %(task_file)s " + "--deployment %(deployment_id)s") % + {"task_file": config.filename, + "deployment_id": deployment_id}) + result = re.search( + r"(?P[0-9a-f\-]{36}): started", output) + uuid = result.group("uuid") + rally("task use --task %s" % uuid) + current_task = envutils.get_global("RALLY_TASK") + self.assertEqual(uuid, current_task) + class SLATestCase(unittest.TestCase):