Improved unittests & added tests for cpl new

This commit is contained in:
2022-05-26 22:21:16 +02:00
parent ce0ad4013f
commit 833dd83008
4 changed files with 35 additions and 29 deletions

View File

@@ -11,22 +11,42 @@ from unittests_shared.cli_commands import CLICommands
class NewTestCase(unittest.TestCase):
def setUp(self):
pass
os.chdir(os.path.abspath(PLAYGROUND_PATH))
def _test_project(self, project_type: str, name: str, *args):
CLICommands.new(project_type, name, *args)
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, String.convert_to_snake_case(name)))
workspace_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, name))
self.assertTrue(os.path.exists(workspace_path))
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, name, 'src', String.convert_to_snake_case(name)))
self.assertTrue(os.path.exists(project_path))
shutil.rmtree(project_path)
self.assertTrue(os.path.join(project_path, f'{name}.json'))
def _test_sub_project(self, project_type: str, name: str, workspace_name: str, *args):
os.chdir(os.path.abspath(os.path.join(os.getcwd(), workspace_name)))
CLICommands.new(project_type, name, *args)
workspace_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, workspace_name))
self.assertTrue(os.path.exists(workspace_path))
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, workspace_name, 'src', String.convert_to_snake_case(name)))
self.assertTrue(os.path.exists(project_path))
self.assertTrue(os.path.join(project_path, f'{name}.json'))
os.chdir(os.path.abspath(os.path.join(os.getcwd(), '../')))
def test_console(self):
print(f'{__name__} new console')
self._test_project('console', 'test-console', '--ab', '--s', '--sp')
def test_sub_console(self):
self._test_sub_project('console', 'test-sub-console', 'test-console', '--ab', '--s', '--sp')
def test_library(self):
print(f'{__name__} new library')
self._test_project('library', 'test-library', '--ab', '--s', '--sp')
def test_sub_library(self):
self._test_sub_project('library', 'test-sub-library', 'test-console', '--ab', '--s', '--sp')
def test_unittest(self):
print(f'{__name__} new unittests')
self._test_project('unittest', 'test-unittest', '--ab', '--s', '--sp')
def test_sub_unittest(self):
self._test_sub_project('unittest', 'test-unittest', 'test-console', '--ab', '--s', '--sp')