sh_cpl/unittests/unittests_cli/cli_test_suite.py

66 lines
2.5 KiB
Python
Raw Normal View History

2022-05-26 13:59:46 +02:00
import os
2022-05-26 14:47:36 +02:00
import shutil
2022-05-26 13:59:46 +02:00
import traceback
2022-05-26 13:49:31 +02:00
import unittest
from unittests_cli.add_test_case import AddTestCase
from unittests_cli.build_test_case import BuildTestCase
2022-05-26 15:29:49 +02:00
from unittests_cli.constants import PLAYGROUND_PATH
2022-05-26 13:49:31 +02:00
from unittests_cli.generate_test_case import GenerateTestCase
from unittests_cli.install_test_case import InstallTestCase
from unittests_cli.new_test_case import NewTestCase
from unittests_cli.publish_test_case import PublishTestCase
from unittests_cli.remove_test_case import RemoveTestCase
from unittests_cli.run_test_case import RunTestCase
from unittests_cli.start_test_case import StartTestCase
from unittests_cli.uninstall_test_case import UninstallTestCase
from unittests_cli.update_test_case import UpdateTestCase
from unittests_cli.version_test_case import VersionTestCase
class CLITestSuite(unittest.TestSuite):
def __init__(self):
unittest.TestSuite.__init__(self)
loader = unittest.TestLoader()
2022-05-26 13:59:46 +02:00
# nothing needed
2022-05-26 13:49:31 +02:00
self.addTests(loader.loadTestsFromTestCase(GenerateTestCase))
self.addTests(loader.loadTestsFromTestCase(NewTestCase))
2022-05-26 13:59:46 +02:00
self.addTests(loader.loadTestsFromTestCase(VersionTestCase))
# project needed
self.addTests(loader.loadTestsFromTestCase(BuildTestCase))
self.addTests(loader.loadTestsFromTestCase(InstallTestCase))
2022-05-26 13:49:31 +02:00
self.addTests(loader.loadTestsFromTestCase(PublishTestCase))
self.addTests(loader.loadTestsFromTestCase(RunTestCase))
self.addTests(loader.loadTestsFromTestCase(StartTestCase))
self.addTests(loader.loadTestsFromTestCase(UninstallTestCase))
self.addTests(loader.loadTestsFromTestCase(UpdateTestCase))
2022-05-26 13:59:46 +02:00
# workspace needed
self.addTests(loader.loadTestsFromTestCase(AddTestCase))
self.addTests(loader.loadTestsFromTestCase(RemoveTestCase))
def _setup(self):
try:
2022-05-26 15:29:49 +02:00
if os.path.exists(PLAYGROUND_PATH):
2022-05-26 15:49:52 +02:00
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, '../')))
2022-05-26 13:59:46 +02:00
2022-05-26 15:49:52 +02:00
os.makedirs(PLAYGROUND_PATH)
2022-05-26 15:29:49 +02:00
os.chdir(PLAYGROUND_PATH)
2022-05-26 13:59:46 +02:00
except Exception as e:
print(f'Setup of {__name__} failed: {traceback.format_exc()}')
def _cleanup(self):
try:
2022-05-26 15:29:49 +02:00
if os.path.exists(PLAYGROUND_PATH):
2022-05-26 15:49:52 +02:00
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, '../')))
2022-05-26 13:59:46 +02:00
except Exception as e:
print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')
2022-05-26 14:47:36 +02:00
def run(self, *args):
self._setup()
super().run(*args)
self._cleanup()