2022.6 #88
@ -25,27 +25,27 @@ class CLITestSuite(unittest.TestSuite):
|
|||||||
|
|
||||||
loader = unittest.TestLoader()
|
loader = unittest.TestLoader()
|
||||||
# nothing needed
|
# nothing needed
|
||||||
self.addTests(loader.loadTestsFromTestCase(GenerateTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(GenerateTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(NewTestCase))
|
self.addTests(loader.loadTestsFromTestCase(NewTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(VersionTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(VersionTestCase))
|
||||||
|
|
||||||
# project needed
|
# project needed
|
||||||
self.addTests(loader.loadTestsFromTestCase(BuildTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(BuildTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(InstallTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(InstallTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(PublishTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(PublishTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(RunTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(RunTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(StartTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(StartTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(UninstallTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(UninstallTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(UpdateTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(UpdateTestCase))
|
||||||
|
|
||||||
# workspace needed
|
# workspace needed
|
||||||
self.addTests(loader.loadTestsFromTestCase(AddTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(AddTestCase))
|
||||||
self.addTests(loader.loadTestsFromTestCase(RemoveTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(RemoveTestCase))
|
||||||
|
|
||||||
def _setup(self):
|
def _setup(self):
|
||||||
try:
|
try:
|
||||||
if os.path.exists(PLAYGROUND_PATH):
|
if os.path.exists(PLAYGROUND_PATH):
|
||||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, '../')))
|
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH)))
|
||||||
|
|
||||||
os.makedirs(PLAYGROUND_PATH)
|
os.makedirs(PLAYGROUND_PATH)
|
||||||
os.chdir(PLAYGROUND_PATH)
|
os.chdir(PLAYGROUND_PATH)
|
||||||
@ -55,7 +55,7 @@ class CLITestSuite(unittest.TestSuite):
|
|||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
try:
|
try:
|
||||||
if os.path.exists(PLAYGROUND_PATH):
|
if os.path.exists(PLAYGROUND_PATH):
|
||||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, '../')))
|
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')
|
print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
PLAYGROUND_PATH = os.path.abspath(os.path.join(os.getcwd(), '../generated/test_cli_playground'))
|
PLAYGROUND_PATH = os.path.abspath(os.path.join(os.getcwd(), '../test_cli_playground'))
|
||||||
CLI_PATH = os.path.abspath(os.path.join(os.getcwd(), '../../src/cpl_cli/main.py'))
|
CLI_PATH = os.path.abspath(os.path.join(os.getcwd(), '../../src/cpl_cli/main.py'))
|
||||||
|
@ -15,28 +15,37 @@ class GenerateTestCase(unittest.TestCase):
|
|||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
||||||
def test_abc(self):
|
def test_abc(self):
|
||||||
|
print(f'{__name__} generate abc')
|
||||||
self._test_file('abc', '_abc')
|
self._test_file('abc', '_abc')
|
||||||
|
|
||||||
def test_class(self):
|
def test_class(self):
|
||||||
|
print(f'{__name__} generate class')
|
||||||
self._test_file('class', '')
|
self._test_file('class', '')
|
||||||
|
|
||||||
def test_enum(self):
|
def test_enum(self):
|
||||||
|
print(f'{__name__} generate enum')
|
||||||
self._test_file('enum', '_enum')
|
self._test_file('enum', '_enum')
|
||||||
|
|
||||||
def test_pipe(self):
|
def test_pipe(self):
|
||||||
|
print(f'{__name__} generate pipe')
|
||||||
self._test_file('pipe', '_pipe')
|
self._test_file('pipe', '_pipe')
|
||||||
|
|
||||||
def test_service(self):
|
def test_service(self):
|
||||||
|
print(f'{__name__} generate service')
|
||||||
self._test_file('service', '_service')
|
self._test_file('service', '_service')
|
||||||
|
|
||||||
def test_settings(self):
|
def test_settings(self):
|
||||||
|
print(f'{__name__} generate settings')
|
||||||
self._test_file('settings', '_settings')
|
self._test_file('settings', '_settings')
|
||||||
|
|
||||||
def test_test_case(self):
|
def test_test_case(self):
|
||||||
|
print(f'{__name__} generate test_case')
|
||||||
self._test_file('test_case', '_test_case')
|
self._test_file('test_case', '_test_case')
|
||||||
|
|
||||||
def test_thread(self):
|
def test_thread(self):
|
||||||
|
print(f'{__name__} generate thread')
|
||||||
self._test_file('thread', '_thread')
|
self._test_file('thread', '_thread')
|
||||||
|
|
||||||
def test_validator(self):
|
def test_validator(self):
|
||||||
|
print(f'{__name__} generate validator')
|
||||||
self._test_file('validator', '_validator')
|
self._test_file('validator', '_validator')
|
||||||
|
@ -1,10 +1,32 @@
|
|||||||
|
import os
|
||||||
|
import shutil
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from cpl_core.utils import String
|
||||||
|
|
||||||
|
from unittests_cli.constants import PLAYGROUND_PATH
|
||||||
|
from unittests_shared.cli_commands import CLICommands
|
||||||
|
|
||||||
|
|
||||||
class NewTestCase(unittest.TestCase):
|
class NewTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_equal(self):
|
def _test_project(self, project_type: str, name: str, *args):
|
||||||
pass
|
CLICommands.new(project_type, name, *args)
|
||||||
|
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, String.convert_to_snake_case(name)))
|
||||||
|
self.assertTrue(os.path.exists(project_path))
|
||||||
|
shutil.rmtree(project_path)
|
||||||
|
|
||||||
|
def test_console(self):
|
||||||
|
print(f'{__name__} new console')
|
||||||
|
self._test_project('console', 'test-console', '--ab', '--s', '--sp')
|
||||||
|
|
||||||
|
def test_library(self):
|
||||||
|
print(f'{__name__} new library')
|
||||||
|
self._test_project('library', 'test-library', '--ab', '--s', '--sp')
|
||||||
|
|
||||||
|
def test_unittest(self):
|
||||||
|
print(f'{__name__} new unittests')
|
||||||
|
self._test_project('unittest', 'test-unittest', '--ab', '--s', '--sp')
|
||||||
|
@ -9,7 +9,7 @@ class CLICommands:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _run(cmd: str, *args):
|
def _run(cmd: str, *args):
|
||||||
env_vars = os.environ
|
env_vars = os.environ
|
||||||
env_vars['CPL_IS_UNITTEST'] = 'YES'
|
# env_vars['CPL_IS_UNITTEST'] = 'YES'
|
||||||
command = ['python', CLI_PATH, cmd]
|
command = ['python', CLI_PATH, cmd]
|
||||||
for arg in args:
|
for arg in args:
|
||||||
command.append(arg)
|
command.append(arg)
|
||||||
@ -17,9 +17,9 @@ class CLICommands:
|
|||||||
subprocess.run(command, env=env_vars)
|
subprocess.run(command, env=env_vars)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls, *args):
|
def generate(cls, schematic: str, name: str):
|
||||||
cls._run('generate', *args)
|
cls._run('generate', schematic, name)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new(cls, *args):
|
def new(cls, project_type: str, name: str, *args):
|
||||||
cls._run('new', *args)
|
cls._run('new', project_type, name, *args)
|
||||||
|
Loading…
Reference in New Issue
Block a user