From 46cceb0910c4af5e27f9a77c2c8167551d085f9d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 26 May 2022 13:59:46 +0200 Subject: [PATCH] Registered CLI test cases --- src/tests/unittests_cli/cli_test_suite.py | 40 ++++++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/tests/unittests_cli/cli_test_suite.py b/src/tests/unittests_cli/cli_test_suite.py index eda27da3..91d3e05b 100644 --- a/src/tests/unittests_cli/cli_test_suite.py +++ b/src/tests/unittests_cli/cli_test_suite.py @@ -1,3 +1,5 @@ +import os +import traceback import unittest from unittests_cli.add_test_case import AddTestCase @@ -19,16 +21,44 @@ class CLITestSuite(unittest.TestSuite): def __init__(self): unittest.TestSuite.__init__(self) + self._setup() + loader = unittest.TestLoader() - self.addTests(loader.loadTestsFromTestCase(AddTestCase)) - self.addTests(loader.loadTestsFromTestCase(BuildTestCase)) + # nothing needed self.addTests(loader.loadTestsFromTestCase(GenerateTestCase)) - self.addTests(loader.loadTestsFromTestCase(InstallTestCase)) self.addTests(loader.loadTestsFromTestCase(NewTestCase)) + self.addTests(loader.loadTestsFromTestCase(VersionTestCase)) + + # project needed + self.addTests(loader.loadTestsFromTestCase(BuildTestCase)) + self.addTests(loader.loadTestsFromTestCase(InstallTestCase)) self.addTests(loader.loadTestsFromTestCase(PublishTestCase)) - self.addTests(loader.loadTestsFromTestCase(RemoveTestCase)) self.addTests(loader.loadTestsFromTestCase(RunTestCase)) self.addTests(loader.loadTestsFromTestCase(StartTestCase)) self.addTests(loader.loadTestsFromTestCase(UninstallTestCase)) self.addTests(loader.loadTestsFromTestCase(UpdateTestCase)) - self.addTests(loader.loadTestsFromTestCase(VersionTestCase)) + + # workspace needed + self.addTests(loader.loadTestsFromTestCase(AddTestCase)) + self.addTests(loader.loadTestsFromTestCase(RemoveTestCase)) + + self._cleanup() + + def _setup(self): + try: + playground = os.path.abspath(os.path.join(os.getcwd(), 'test_cli_playground')) + if os.path.exists(playground): + os.rmdir(playground) + + os.mkdir(playground) + os.chdir(playground) + except Exception as e: + print(f'Setup of {__name__} failed: {traceback.format_exc()}') + + def _cleanup(self): + try: + playground = os.path.abspath(os.path.join(os.getcwd(), 'test_cli_playground')) + if os.path.exists(playground): + os.rmdir(playground) + except Exception as e: + print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')