From 0ead7c9e03034bbb40b68a468a6deaa339b0364e Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Sun, 2 Jul 2017 12:56:09 +0200 Subject: Update cli commands to call console scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I401879d7ec713b5307817da8b001838c35d9d731 Signed-off-by: Cédric Ollivier --- functest/cli/commands/cli_env.py | 5 +---- functest/cli/commands/cli_testcase.py | 5 +---- functest/cli/commands/cli_tier.py | 3 +-- functest/tests/unit/cli/commands/test_cli_env.py | 7 ++----- .../tests/unit/cli/commands/test_cli_testcase.py | 21 ++++----------------- functest/tests/unit/cli/commands/test_cli_tier.py | 21 ++++----------------- 6 files changed, 13 insertions(+), 49 deletions(-) diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py index ce977572..99d36996 100644 --- a/functest/cli/commands/cli_env.py +++ b/functest/cli/commands/cli_env.py @@ -8,7 +8,6 @@ # import os -import pkg_resources import click import prettytable @@ -36,9 +35,7 @@ class CliEnv(object): else: answer = raw_input("Invalid answer. Please type [y|n]\n") - cmd = ("python %s start" % pkg_resources.resource_filename( - 'functest', 'ci/prepare_env.py')) - ft_utils.execute_command(cmd) + ft_utils.execute_command("prepare_env start") def show(self): def _get_value(attr, default='Unknown'): diff --git a/functest/cli/commands/cli_testcase.py b/functest/cli/commands/cli_testcase.py index 91904d87..cb3d4739 100644 --- a/functest/cli/commands/cli_testcase.py +++ b/functest/cli/commands/cli_testcase.py @@ -60,8 +60,5 @@ class CliTestcase(object): else: tests = testname.split(",") for test in tests: - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - flags, test)) + cmd = "run_tests {}-t {}".format(flags, test) ft_utils.execute_command(cmd) diff --git a/functest/cli/commands/cli_tier.py b/functest/cli/commands/cli_tier.py index 48e9f542..9b2e60ba 100644 --- a/functest/cli/commands/cli_tier.py +++ b/functest/cli/commands/cli_tier.py @@ -68,6 +68,5 @@ class CliTier(object): click.echo("Functest environment is not ready. " "Run first 'functest env prepare'") else: - cmd = ("python %s %s -t %s" % (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), flags, tiername)) + cmd = "run_tests {}-t {}".format(flags, tiername) ft_utils.execute_command(cmd) diff --git a/functest/tests/unit/cli/commands/test_cli_env.py b/functest/tests/unit/cli/commands/test_cli_env.py index 0b18554b..ddd5d86c 100644 --- a/functest/tests/unit/cli/commands/test_cli_env.py +++ b/functest/tests/unit/cli/commands/test_cli_env.py @@ -6,7 +6,6 @@ # http://www.apache.org/licenses/LICENSE-2.0 import logging -import pkg_resources import unittest import mock @@ -25,8 +24,7 @@ class CliEnvTesting(unittest.TestCase): return_value=False) @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command') def test_prepare_default(self, mock_ft_utils, mock_os): - cmd = ("python %s start" % pkg_resources.resource_filename( - 'functest', 'ci/prepare_env.py')) + cmd = "prepare_env start" self.cli_environ.prepare() mock_ft_utils.assert_called_with(cmd) @@ -37,8 +35,7 @@ class CliEnvTesting(unittest.TestCase): with mock.patch('__builtin__.raw_input', return_value="y"), \ mock.patch('functest.cli.commands.cli_testcase.os.remove') \ as mock_os_remove: - cmd = ("python %s start" % pkg_resources.resource_filename( - 'functest', 'ci/prepare_env.py')) + cmd = "prepare_env start" self.cli_environ.prepare() mock_os_remove.assert_called_once_with( CONST.__getattribute__('env_active')) diff --git a/functest/tests/unit/cli/commands/test_cli_testcase.py b/functest/tests/unit/cli/commands/test_cli_testcase.py index 4d0bdc2f..9ccf4c4a 100644 --- a/functest/tests/unit/cli/commands/test_cli_testcase.py +++ b/functest/tests/unit/cli/commands/test_cli_testcase.py @@ -7,7 +7,6 @@ import logging -import pkg_resources import unittest import mock @@ -39,10 +38,7 @@ class CliTestCasesTesting(unittest.TestCase): return_value=True) @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command') def test_run_default(self, mock_ft_utils, mock_os): - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - "-n -r ", self.testname)) + cmd = "run_tests -n -r -t {}".format(self.testname) self.cli_tests.run(self.testname, noclean=True, report=True) mock_ft_utils.assert_called_with(cmd) @@ -50,10 +46,7 @@ class CliTestCasesTesting(unittest.TestCase): return_value=True) @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command') def test_run_noclean_missing_report(self, mock_ft_utils, mock_os): - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - "-n ", self.testname)) + cmd = "run_tests -n -t {}".format(self.testname) self.cli_tests.run(self.testname, noclean=True, report=False) mock_ft_utils.assert_called_with(cmd) @@ -61,10 +54,7 @@ class CliTestCasesTesting(unittest.TestCase): return_value=True) @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command') def test_run_report_missing_noclean(self, mock_ft_utils, mock_os): - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - "-r ", self.testname)) + cmd = "run_tests -r -t {}".format(self.testname) self.cli_tests.run(self.testname, noclean=False, report=True) mock_ft_utils.assert_called_with(cmd) @@ -72,10 +62,7 @@ class CliTestCasesTesting(unittest.TestCase): return_value=True) @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command') def test_run_missing_noclean_report(self, mock_ft_utils, mock_os): - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - "", self.testname)) + cmd = "run_tests -t {}".format(self.testname) self.cli_tests.run(self.testname, noclean=False, report=False) mock_ft_utils.assert_called_with(cmd) diff --git a/functest/tests/unit/cli/commands/test_cli_tier.py b/functest/tests/unit/cli/commands/test_cli_tier.py index b42e3581..1bb630db 100644 --- a/functest/tests/unit/cli/commands/test_cli_tier.py +++ b/functest/tests/unit/cli/commands/test_cli_tier.py @@ -7,7 +7,6 @@ import logging -import pkg_resources import unittest import mock @@ -87,10 +86,7 @@ class CliTierTesting(unittest.TestCase): return_value=True) @mock.patch('functest.cli.commands.cli_tier.ft_utils.execute_command') def test_run_default(self, mock_ft_utils, mock_os): - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - "-n -r ", self.tiername)) + cmd = "run_tests -n -r -t {}".format(self.tiername) self.cli_tier.run(self.tiername, noclean=True, report=True) mock_ft_utils.assert_called_with(cmd) @@ -98,10 +94,7 @@ class CliTierTesting(unittest.TestCase): return_value=True) @mock.patch('functest.cli.commands.cli_tier.ft_utils.execute_command') def test_run_report_missing_noclean(self, mock_ft_utils, mock_os): - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - "-r ", self.tiername)) + cmd = "run_tests -r -t {}".format(self.tiername) self.cli_tier.run(self.tiername, noclean=False, report=True) mock_ft_utils.assert_called_with(cmd) @@ -109,10 +102,7 @@ class CliTierTesting(unittest.TestCase): return_value=True) @mock.patch('functest.cli.commands.cli_tier.ft_utils.execute_command') def test_run_noclean_missing_report(self, mock_ft_utils, mock_os): - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - "-n ", self.tiername)) + cmd = "run_tests -n -t {}".format(self.tiername) self.cli_tier.run(self.tiername, noclean=True, report=False) mock_ft_utils.assert_called_with(cmd) @@ -120,10 +110,7 @@ class CliTierTesting(unittest.TestCase): return_value=True) @mock.patch('functest.cli.commands.cli_tier.ft_utils.execute_command') def test_run_missing_noclean_report(self, mock_ft_utils, mock_os): - cmd = ("python %s %s -t %s" % - (pkg_resources.resource_filename( - 'functest', 'ci/run_tests.py'), - "", self.tiername)) + cmd = "run_tests -t {}".format(self.tiername) self.cli_tier.run(self.tiername, noclean=False, report=False) mock_ft_utils.assert_called_with(cmd) -- cgit 1.2.3-korg