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):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate abc')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('abc', '_abc')
|
|
|
|
|
|
|
|
def test_class(self):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate class')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('class', '')
|
|
|
|
|
|
|
|
def test_enum(self):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate enum')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('enum', '_enum')
|
|
|
|
|
|
|
|
def test_pipe(self):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate pipe')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('pipe', '_pipe')
|
|
|
|
|
|
|
|
def test_service(self):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate service')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('service', '_service')
|
|
|
|
|
|
|
|
def test_settings(self):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate settings')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('settings', '_settings')
|
|
|
|
|
|
|
|
def test_test_case(self):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate test_case')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('test_case', '_test_case')
|
|
|
|
|
|
|
|
def test_thread(self):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate thread')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('thread', '_thread')
|
|
|
|
|
|
|
|
def test_validator(self):
|
2022-05-26 21:42:43 +02:00
|
|
|
print(f'{__name__} generate validator')
|
2022-05-26 14:47:36 +02:00
|
|
|
self._test_file('validator', '_validator')
|