sh_cpl/unittests/unittests_cli/generate_test_case.py

43 lines
1.1 KiB
Python
Raw Normal View History

2022-05-26 14:47:36 +02:00
import os.path
2022-05-26 13:49:31 +02:00
import unittest
2022-05-26 15:29:49 +02:00
from unittests_cli.constants import PLAYGROUND_PATH
2022-05-26 14:47:36 +02:00
from unittests_shared.cli_commands import CLICommands
2022-05-26 13:49:31 +02:00
class GenerateTestCase(unittest.TestCase):
2022-05-26 14:47:36 +02:00
def _test_file(self, schematic: str, suffix: str):
CLICommands.generate(schematic, 'GeneratedFile')
2022-05-26 15:29:49 +02:00
file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, f'generated_file{suffix}.py'))
2022-05-26 14:47:36 +02:00
file_exists = os.path.exists(file_path)
self.assertTrue(file_exists)
os.remove(file_path)
def test_abc(self):
self._test_file('abc', '_abc')
def test_class(self):
self._test_file('class', '')
def test_enum(self):
self._test_file('enum', '_enum')
def test_pipe(self):
self._test_file('pipe', '_pipe')
def test_service(self):
self._test_file('service', '_service')
def test_settings(self):
self._test_file('settings', '_settings')
def test_test_case(self):
self._test_file('test_case', '_test_case')
def test_thread(self):
self._test_file('thread', '_thread')
def test_validator(self):
self._test_file('validator', '_validator')