Moved unittests
This commit is contained in:
1
unittests/unittests/__init__.py
Normal file
1
unittests/unittests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# imports:
|
19
unittests/unittests/application.py
Normal file
19
unittests/unittests/application.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import unittest
|
||||
|
||||
from cpl_core.application import ApplicationABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from unittests_cli.cli_test_suite import CLITestSuite
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def main(self):
|
||||
runner = unittest.TextTestRunner()
|
||||
runner.run(CLITestSuite())
|
11
unittests/unittests/main.py
Normal file
11
unittests/unittests/main.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from cpl_core.application import ApplicationBuilder
|
||||
from unittests.application import Application
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
43
unittests/unittests/unittests.json
Normal file
43
unittests/unittests/unittests.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "unittests",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2022.6.17.dev4"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
"linux": ""
|
||||
},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"ProjectType": "unittest",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "unittest.main",
|
||||
"EntryPoint": "unittest",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
1
unittests/unittests_cli/__init__.py
Normal file
1
unittests/unittests_cli/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# imports:
|
10
unittests/unittests_cli/add_test_case.py
Normal file
10
unittests/unittests_cli/add_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class AddTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
10
unittests/unittests_cli/build_test_case.py
Normal file
10
unittests/unittests_cli/build_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class BuildTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
67
unittests/unittests_cli/cli_test_suite.py
Normal file
67
unittests/unittests_cli/cli_test_suite.py
Normal file
@@ -0,0 +1,67 @@
|
||||
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_PATH
|
||||
from unittests_cli.generate_test_case import GenerateTestCase
|
||||
from unittests_cli.install_test_case import InstallTestCase
|
||||
from unittests_cli.new_test_case import NewTestCase
|
||||
from unittests_cli.publish_test_case import PublishTestCase
|
||||
from unittests_cli.remove_test_case import RemoveTestCase
|
||||
from unittests_cli.run_test_case import RunTestCase
|
||||
from unittests_cli.start_test_case import StartTestCase
|
||||
from unittests_cli.uninstall_test_case import UninstallTestCase
|
||||
from unittests_cli.update_test_case import UpdateTestCase
|
||||
from unittests_cli.version_test_case import VersionTestCase
|
||||
|
||||
|
||||
class CLITestSuite(unittest.TestSuite):
|
||||
|
||||
def __init__(self):
|
||||
unittest.TestSuite.__init__(self)
|
||||
|
||||
loader = unittest.TestLoader()
|
||||
# nothing needed
|
||||
self.addTests(loader.loadTestsFromTestCase(GenerateTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(NewTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(VersionTestCase))
|
||||
|
||||
# project needed
|
||||
self.addTests(loader.loadTestsFromTestCase(BuildTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(InstallTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(PublishTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(RunTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(StartTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(UninstallTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(UpdateTestCase))
|
||||
|
||||
# workspace needed
|
||||
self.addTests(loader.loadTestsFromTestCase(AddTestCase))
|
||||
self.addTests(loader.loadTestsFromTestCase(RemoveTestCase))
|
||||
|
||||
def _setup(self):
|
||||
print(f'Setup {__name__}')
|
||||
try:
|
||||
if os.path.exists(PLAYGROUND_PATH):
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, '../')))
|
||||
|
||||
os.makedirs(PLAYGROUND_PATH)
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
except Exception as e:
|
||||
print(f'Setup of {__name__} failed: {traceback.format_exc()}')
|
||||
|
||||
def _cleanup(self):
|
||||
print(f'Cleanup {__name__}')
|
||||
try:
|
||||
if os.path.exists(PLAYGROUND_PATH):
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, '../')))
|
||||
except Exception as e:
|
||||
print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')
|
||||
|
||||
def run(self, *args):
|
||||
self._setup()
|
||||
super().run(*args)
|
||||
self._cleanup()
|
4
unittests/unittests_cli/constants.py
Normal file
4
unittests/unittests_cli/constants.py
Normal file
@@ -0,0 +1,4 @@
|
||||
import os
|
||||
|
||||
PLAYGROUND_PATH = os.path.abspath(os.path.join(os.getcwd(), '../generated/test_cli_playground'))
|
||||
CLI_PATH = os.path.abspath(os.path.join(os.getcwd(), '../../src/cpl_cli/main.py'))
|
10
unittests/unittests_cli/custom_test_case.py
Normal file
10
unittests/unittests_cli/custom_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class CustomTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
42
unittests/unittests_cli/generate_test_case.py
Normal file
42
unittests/unittests_cli/generate_test_case.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import os.path
|
||||
import unittest
|
||||
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class GenerateTestCase(unittest.TestCase):
|
||||
|
||||
def _test_file(self, schematic: str, suffix: str):
|
||||
CLICommands.generate(schematic, 'GeneratedFile')
|
||||
file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, 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')
|
10
unittests/unittests_cli/install_test_case.py
Normal file
10
unittests/unittests_cli/install_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class InstallTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
10
unittests/unittests_cli/new_test_case.py
Normal file
10
unittests/unittests_cli/new_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class NewTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
10
unittests/unittests_cli/publish_test_case.py
Normal file
10
unittests/unittests_cli/publish_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class PublishTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
10
unittests/unittests_cli/remove_test_case.py
Normal file
10
unittests/unittests_cli/remove_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class RemoveTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
10
unittests/unittests_cli/run_test_case.py
Normal file
10
unittests/unittests_cli/run_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class RunTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
10
unittests/unittests_cli/start_test_case.py
Normal file
10
unittests/unittests_cli/start_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class StartTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
10
unittests/unittests_cli/uninstall_test_case.py
Normal file
10
unittests/unittests_cli/uninstall_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class UninstallTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
43
unittests/unittests_cli/unittests_cli.json
Normal file
43
unittests/unittests_cli/unittests_cli.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "unittest_cli",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2022.6.17.dev4"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
"linux": ""
|
||||
},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"ProjectType": "library",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "unittest_cli.main",
|
||||
"EntryPoint": "unittest_cli",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
10
unittests/unittests_cli/update_test_case.py
Normal file
10
unittests/unittests_cli/update_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class UpdateTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
10
unittests/unittests_cli/version_test_case.py
Normal file
10
unittests/unittests_cli/version_test_case.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import unittest
|
||||
|
||||
|
||||
class VersionTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
1
unittests/unittests_core/__init__.py
Normal file
1
unittests/unittests_core/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# imports:
|
43
unittests/unittests_core/unittests_core.json
Normal file
43
unittests/unittests_core/unittests_core.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "unittest_core",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2022.6.17.dev4"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
"linux": ""
|
||||
},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"ProjectType": "library",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "unittest_core.main",
|
||||
"EntryPoint": "unittest_core",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
1
unittests/unittests_query/__init__.py
Normal file
1
unittests/unittests_query/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# imports:
|
43
unittests/unittests_query/unittests_query.json
Normal file
43
unittests/unittests_query/unittests_query.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "unittest_query",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2022.6.17.dev4"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
"linux": ""
|
||||
},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"ProjectType": "library",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "unittest_query.main",
|
||||
"EntryPoint": "unittest_query",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
1
unittests/unittests_shared/__init__.py
Normal file
1
unittests/unittests_shared/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# imports:
|
26
unittests/unittests_shared/cli_commands.py
Normal file
26
unittests/unittests_shared/cli_commands.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from unittests_cli.constants import CLI_PATH
|
||||
|
||||
|
||||
class CLICommands:
|
||||
|
||||
@staticmethod
|
||||
def _run(cmd: str, *args):
|
||||
env_vars = os.environ
|
||||
env_vars['CPL_IS_UNITTEST'] = 'YES'
|
||||
command = ['python', CLI_PATH, 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)
|
43
unittests/unittests_shared/unittests_shared.json
Normal file
43
unittests/unittests_shared/unittests_shared.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "unittest_shared",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2022.6.17.dev4"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {
|
||||
"linux": ""
|
||||
},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"ProjectType": "library",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "unittest_shared.main",
|
||||
"EntryPoint": "unittest_shared",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user