From dad4913bcdb1a73575d6ef52c7aa2e229444ada7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 3 Jun 2022 23:44:26 +0200 Subject: [PATCH] Added cpl remove test --- unittests/unittests_cli/cli_test_suite.py | 3 ++- unittests/unittests_cli/remove_test_case.py | 30 ++++++++++++++++++--- unittests/unittests_shared/cli_commands.py | 4 +++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/unittests/unittests_cli/cli_test_suite.py b/unittests/unittests_cli/cli_test_suite.py index ffc3eb95..58638afb 100644 --- a/unittests/unittests_cli/cli_test_suite.py +++ b/unittests/unittests_cli/cli_test_suite.py @@ -9,6 +9,7 @@ from unittests_cli.add_test_case import AddTestCase from unittests_cli.constants import PLAYGROUND_PATH from unittests_cli.generate_test_case import GenerateTestCase from unittests_cli.new_test_case import NewTestCase +from unittests_cli.remove_test_case import RemoveTestCase class CLITestSuite(unittest.TestSuite): @@ -34,7 +35,7 @@ class CLITestSuite(unittest.TestSuite): # workspace needed self.addTests(loader.loadTestsFromTestCase(AddTestCase)) - # self.addTests(loader.loadTestsFromTestCase(RemoveTestCase)) + self.addTests(loader.loadTestsFromTestCase(RemoveTestCase)) def _setup(self): try: diff --git a/unittests/unittests_cli/remove_test_case.py b/unittests/unittests_cli/remove_test_case.py index a600c283..a397c44f 100644 --- a/unittests/unittests_cli/remove_test_case.py +++ b/unittests/unittests_cli/remove_test_case.py @@ -1,10 +1,32 @@ +import json +import os +import shutil import unittest +from cpl_core.utils import String + +from unittests_cli.constants import PLAYGROUND_PATH +from unittests_shared.cli_commands import CLICommands + class RemoveTestCase(unittest.TestCase): - def setUp(self): - pass + def __init__(self, methodName: str): + unittest.TestCase.__init__(self, methodName) + self._source = 'add-test-project' + self._target = 'add-test-library' + self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json' - def test_equal(self): - pass + def setUp(self): + os.chdir(os.path.abspath(PLAYGROUND_PATH)) + # create projects + CLICommands.new('console', self._source, '--ab', '--s') + os.chdir(os.path.join(os.getcwd(), self._source)) + CLICommands.new('console', self._target, '--ab', '--s') + + def test_remove(self): + CLICommands.remove(self._target) + path = os.path.abspath(os.path.join(os.getcwd(), f'../{String.convert_to_snake_case(self._target)}')) + self.assertTrue(os.path.exists(os.getcwd())) + self.assertTrue(os.path.exists(os.path.join(os.getcwd(), self._project_file))) + self.assertFalse(os.path.exists(path)) diff --git a/unittests/unittests_shared/cli_commands.py b/unittests/unittests_shared/cli_commands.py index 68ed508c..dd1e0029 100644 --- a/unittests/unittests_shared/cli_commands.py +++ b/unittests/unittests_shared/cli_commands.py @@ -28,3 +28,7 @@ class CLICommands: @classmethod def new(cls, project_type: str, name: str, *args, output=False): cls._run('new', project_type, name, *args, output=output) + + @classmethod + def remove(cls, project: str): + cls._run('remove', project)