2022.6 #88

Merged
edraft merged 158 commits from 2022.6 into master 2022-06-29 17:50:07 +02:00
10 changed files with 89 additions and 25 deletions
Showing only changes of commit d937c4c0e6 - Show all commits

View File

@ -1,5 +1,5 @@
import time
import unittest
from unittest import TestSuite
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC

View File

@ -28,8 +28,8 @@
"ProjectType": "unittest",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "tests/unittest.main",
"EntryPoint": "tests/unittest",
"Main": "unittest.main",
"EntryPoint": "unittest",
"IncludePackageData": false,
"Included": [],
"Excluded": [

View File

@ -1,9 +1,11 @@
import os
import shutil
import traceback
import unittest
from unittests_cli.add_test_case import AddTestCase
from unittests_cli.build_test_case import BuildTestCase
from unittests_cli.constants import PLAYGROUND
from unittests_cli.generate_test_case import GenerateTestCase
from unittests_cli.install_test_case import InstallTestCase
from unittests_cli.new_test_case import NewTestCase
@ -21,8 +23,6 @@ class CLITestSuite(unittest.TestSuite):
def __init__(self):
unittest.TestSuite.__init__(self)
self._setup()
loader = unittest.TestLoader()
# nothing needed
self.addTests(loader.loadTestsFromTestCase(GenerateTestCase))
@ -42,23 +42,26 @@ class CLITestSuite(unittest.TestSuite):
self.addTests(loader.loadTestsFromTestCase(AddTestCase))
self.addTests(loader.loadTestsFromTestCase(RemoveTestCase))
self._cleanup()
def _setup(self):
print(f'Setup {__name__}')
try:
playground = os.path.abspath(os.path.join(os.getcwd(), 'test_cli_playground'))
if os.path.exists(playground):
os.rmdir(playground)
if os.path.exists(PLAYGROUND):
shutil.rmtree(PLAYGROUND)
os.mkdir(playground)
os.chdir(playground)
os.mkdir(PLAYGROUND)
os.chdir(PLAYGROUND)
except Exception as e:
print(f'Setup of {__name__} failed: {traceback.format_exc()}')
def _cleanup(self):
print(f'Cleanup {__name__}')
try:
playground = os.path.abspath(os.path.join(os.getcwd(), 'test_cli_playground'))
if os.path.exists(playground):
os.rmdir(playground)
if os.path.exists(PLAYGROUND):
shutil.rmtree(PLAYGROUND)
except Exception as e:
print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')
def run(self, *args):
self._setup()
super().run(*args)
self._cleanup()

View File

@ -0,0 +1,3 @@
import os
PLAYGROUND = os.path.abspath(os.path.join(os.getcwd(), '../generated/test_cli_playground'))

View File

@ -1,10 +1,45 @@
import os.path
import unittest
from unittests_cli.constants import PLAYGROUND
from unittests_shared.cli_commands import CLICommands
class GenerateTestCase(unittest.TestCase):
def setUp(self):
pass
def test_equal(self):
pass
def _test_file(self, schematic: str, suffix: str):
CLICommands.generate(schematic, 'GeneratedFile')
file_path = os.path.abspath(os.path.join(PLAYGROUND, f'generated_file{suffix}.py'))
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')

View File

@ -28,8 +28,8 @@
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "tests/unittest_cli.main",
"EntryPoint": "tests/unittest_cli",
"Main": "unittest_cli.main",
"EntryPoint": "unittest_cli",
"IncludePackageData": false,
"Included": [],
"Excluded": [

View File

@ -28,8 +28,8 @@
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "tests/unittest_core.main",
"EntryPoint": "tests/unittest_core",
"Main": "unittest_core.main",
"EntryPoint": "unittest_core",
"IncludePackageData": false,
"Included": [],
"Excluded": [

View File

@ -28,8 +28,8 @@
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "tests/unittest_query.main",
"EntryPoint": "tests/unittest_query",
"Main": "unittest_query.main",
"EntryPoint": "unittest_query",
"IncludePackageData": false,
"Included": [],
"Excluded": [

View File

@ -0,0 +1,23 @@
import os
import subprocess
class CLICommands:
@staticmethod
def _run(cmd: str, *args):
env_vars = os.environ
command = ['python', os.path.abspath(os.path.join(os.getcwd(), '../../../cpl_cli/main.py')), cmd]
for arg in args:
command.append(arg)
print(f'Running {command}')
subprocess.run(command, env=env_vars)
@classmethod
def generate(cls, *args):
cls._run('generate', *args)
@classmethod
def new(cls, *args):
cls._run('new', *args)

View File

@ -28,8 +28,8 @@
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "tests/unittest_shared.main",
"EntryPoint": "tests/unittest_shared",
"Main": "unittest_shared.main",
"EntryPoint": "unittest_shared",
"IncludePackageData": false,
"Included": [],
"Excluded": [