2022.6.17 - Unittests #84
41
src/cpl_cli/_templates/generate/test_case_template.py
Normal file
41
src/cpl_cli/_templates/generate/test_case_template.py
Normal file
@ -0,0 +1,41 @@
|
||||
import textwrap
|
||||
from string import Template
|
||||
|
||||
from cpl_core.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class TestCaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py'
|
||||
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||
self._path = path
|
||||
self._value = textwrap.dedent("""\
|
||||
import unittest
|
||||
|
||||
|
||||
class $Name(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return Template(self._value).substitute(
|
||||
Name=self._class_name
|
||||
)
|
@ -2,21 +2,22 @@ import os
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
from cpl_cli._templates.generate.pipe_template import PipeTemplate
|
||||
from cpl_cli._templates.generate.validator_template import ValidatorTemplate
|
||||
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl_core.console.foreground_color_enum import ForegroundColorEnum
|
||||
from cpl_core.console.console import Console
|
||||
from cpl_core.utils.string import String
|
||||
from cpl_cli.command_abc import CommandABC
|
||||
from cpl_cli._templates.generate.init_template import InitTemplate
|
||||
from cpl_cli._templates.generate.abc_template import ABCTemplate
|
||||
from cpl_cli._templates.generate.class_template import ClassTemplate
|
||||
from cpl_cli._templates.generate.configmodel_template import ConfigModelTemplate
|
||||
from cpl_cli._templates.generate.enum_template import EnumTemplate
|
||||
from cpl_cli._templates.generate.init_template import InitTemplate
|
||||
from cpl_cli._templates.generate.pipe_template import PipeTemplate
|
||||
from cpl_cli._templates.generate.service_template import ServiceTemplate
|
||||
from cpl_cli._templates.generate.test_case_template import TestCaseTemplate
|
||||
from cpl_cli._templates.generate.thread_template import ThreadTemplate
|
||||
from cpl_cli._templates.generate.validator_template import ValidatorTemplate
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
from cpl_cli.command_abc import CommandABC
|
||||
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl_core.console.console import Console
|
||||
from cpl_core.console.foreground_color_enum import ForegroundColorEnum
|
||||
from cpl_core.utils.string import String
|
||||
|
||||
|
||||
class GenerateService(CommandABC):
|
||||
@ -53,6 +54,10 @@ class GenerateService(CommandABC):
|
||||
"Upper": "Settings",
|
||||
"Template": ConfigModelTemplate
|
||||
},
|
||||
"test_case": {
|
||||
"Upper": "TestCase",
|
||||
"Template": TestCaseTemplate
|
||||
},
|
||||
"thread": {
|
||||
"Upper": "Thread",
|
||||
"Template": ThreadTemplate
|
||||
@ -83,6 +88,7 @@ class GenerateService(CommandABC):
|
||||
pipe
|
||||
service
|
||||
settings
|
||||
test_case
|
||||
thread
|
||||
validator
|
||||
""")
|
||||
@ -103,6 +109,7 @@ class GenerateService(CommandABC):
|
||||
'pipe (p|P)',
|
||||
'service (s|S)',
|
||||
'settings (st|ST)',
|
||||
'test-case (tc|TC)',
|
||||
'thread (t|T)',
|
||||
'validator (v|V)'
|
||||
]
|
||||
|
@ -77,6 +77,7 @@ class StartupArgumentExtension(StartupExtensionABC):
|
||||
.add_console_argument(ArgumentTypeEnum.Variable, '', 'pipe', ['p', 'P'], ' ') \
|
||||
.add_console_argument(ArgumentTypeEnum.Variable, '', 'service', ['s', 'S'], ' ') \
|
||||
.add_console_argument(ArgumentTypeEnum.Variable, '', 'settings', ['st', 'ST'], ' ') \
|
||||
.add_console_argument(ArgumentTypeEnum.Variable, '', 'test_case', ['tc', 'TC'], ' ') \
|
||||
.add_console_argument(ArgumentTypeEnum.Variable, '', 'thread', ['t', 'T'], ' ') \
|
||||
.add_console_argument(ArgumentTypeEnum.Variable, '', 'validator', ['v', 'V'], ' ')
|
||||
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'install', ['i', 'I'], InstallService, True, validators=[ProjectValidator]) \
|
||||
|
Loading…
Reference in New Issue
Block a user