Improved tests

This commit is contained in:
Sven Heidemann 2022-05-26 15:29:49 +02:00
parent d937c4c0e6
commit a72dd0dc2e
6 changed files with 25 additions and 15 deletions

View File

@ -15,14 +15,20 @@
}, },
"Scripts": { "Scripts": {
"hello-world": "echo 'Hello World'", "hello-world": "echo 'Hello World'",
"sv": "cpl set-version", "sv": "cpl set-version",
"set-version": "cpl run set-version $ARGS; echo '';", "set-version": "cpl run set-version $ARGS; echo '';",
"spu": "cpl set-pip-urls", "spu": "cpl set-pip-urls",
"set-pip-urls": "cpl run set-pip-urls $ARGS; echo '';", "set-pip-urls": "cpl run set-pip-urls $ARGS; echo '';",
"docs-build": "echo 'Build Documentation'; cd docs/; sphinx-apidoc -o source/ ../src/cpl_core; sphinx-apidoc -o source/ ../src/cpl_query; make clean; make html; rm source/cpl_query.tests.rst;", "docs-build": "echo 'Build Documentation'; cd docs/; sphinx-apidoc -o source/ ../src/cpl_core; sphinx-apidoc -o source/ ../src/cpl_query; make clean; make html; rm source/cpl_query.tests.rst;",
"db": "cpl build-docs", "db": "cpl build-docs",
"docs-open": "xdg-open $PWD/docs/build/html/index.html &", "docs-open": "xdg-open $PWD/docs/build/html/index.html &",
"do": "cpl docs-open", "do": "cpl docs-open",
"test": "cpl run unittests",
"pre-build-all": "cpl sv $ARGS; cpl spu $ARGS;", "pre-build-all": "cpl sv $ARGS; cpl spu $ARGS;",
"build-all": "cpl build-cli; cpl build-core; cpl build-query; cpl build-set-pip-urls; cpl build-set-version", "build-all": "cpl build-cli; cpl build-core; cpl build-query; cpl build-set-pip-urls; cpl build-set-version",
"ba": "cpl build-all $ARGS", "ba": "cpl build-all $ARGS",
@ -31,12 +37,14 @@
"build-query": "echo 'Build cpl-query'; cd ./src/cpl_query; cpl build; cd ../../;", "build-query": "echo 'Build cpl-query'; cd ./src/cpl_query; cpl build; cd ../../;",
"build-set-pip-urls": "echo 'Build set-pip-urls'; cd ./tools/set_pip_urls; cpl build; cd ../../;", "build-set-pip-urls": "echo 'Build set-pip-urls'; cd ./tools/set_pip_urls; cpl build; cd ../../;",
"build-set-version": "echo 'Build set-version'; cd ./tools/set_version; cpl build; cd ../../;", "build-set-version": "echo 'Build set-version'; cd ./tools/set_version; cpl build; cd ../../;",
"pre-publish-all": "cpl sv $ARGS; cpl spu $ARGS;", "pre-publish-all": "cpl sv $ARGS; cpl spu $ARGS;",
"publish-all": "cpl publish-cli; cpl publish-core; cpl publish-query;", "publish-all": "cpl publish-cli; cpl publish-core; cpl publish-query;",
"pa": "cpl build-all $ARGS", "pa": "cpl build-all $ARGS",
"publish-cli": "echo 'Publish cpl-cli'; cd ./src/cpl_cli; cpl publish; cd ../../;", "publish-cli": "echo 'Publish cpl-cli'; cd ./src/cpl_cli; cpl publish; cd ../../;",
"publish-core": "echo 'Publish cpl-core'; cd ./src/cpl_core; cpl publish; cd ../../;", "publish-core": "echo 'Publish cpl-core'; cd ./src/cpl_core; cpl publish; cd ../../;",
"publish-query": "echo 'Publish cpl_query'; cd ./src/cpl_query; cpl publish; cd ../../;", "publish-query": "echo 'Publish cpl_query'; cd ./src/cpl_query; cpl publish; cd ../../;",
"upload-prod-cli": "echo 'PROD Upload cpl-cli'; cpl upl-prod-cli;", "upload-prod-cli": "echo 'PROD Upload cpl-cli'; cpl upl-prod-cli;",
"upl-prod-cli": "twine upload -r pip.sh-edraft.de dist/cpl-cli/publish/setup/*", "upl-prod-cli": "twine upload -r pip.sh-edraft.de dist/cpl-cli/publish/setup/*",
"upload-prod-core": "echo 'PROD Upload cpl-core'; cpl upl-prod-core;", "upload-prod-core": "echo 'PROD Upload cpl-core'; cpl upl-prod-core;",
@ -55,18 +63,21 @@
"upl-dev-core": "twine upload -r pip-dev.sh-edraft.de dist/cpl-core/publish/setup/*", "upl-dev-core": "twine upload -r pip-dev.sh-edraft.de dist/cpl-core/publish/setup/*",
"upload-dev-query": "echo 'DEV Upload cpl_query'; cpl upl-dev-query;", "upload-dev-query": "echo 'DEV Upload cpl_query'; cpl upl-dev-query;",
"upl-dev-query": "twine upload -r pip-dev.sh-edraft.de dist/cpl-query/publish/setup/*", "upl-dev-query": "twine upload -r pip-dev.sh-edraft.de dist/cpl-query/publish/setup/*",
"pre-deploy-prod": "cpl sv $ARGS; cpl spu --environment=production;", "pre-deploy-prod": "cpl sv $ARGS; cpl spu --environment=production;",
"deploy-prod": "cpl deploy-prod-cli; cpl deploy-prod-core; cpl deploy-prod-query;", "deploy-prod": "cpl deploy-prod-cli; cpl deploy-prod-core; cpl deploy-prod-query;",
"dp": "cpl deploy-prod $ARGS", "dp": "cpl deploy-prod $ARGS",
"deploy-prod-cli": "cpl publish-cli; cpl upload-prod-cli", "deploy-prod-cli": "cpl publish-cli; cpl upload-prod-cli",
"deploy-prod-core": "cpl publish-core; cpl upload-prod-core", "deploy-prod-core": "cpl publish-core; cpl upload-prod-core",
"deploy-prod-query": "cpl publish-query; cpl upload-prod-query", "deploy-prod-query": "cpl publish-query; cpl upload-prod-query",
"pre-deploy-exp": "cpl sv $ARGS; cpl spu --environment=staging;", "pre-deploy-exp": "cpl sv $ARGS; cpl spu --environment=staging;",
"deploy-exp": "cpl deploy-exp-cli; cpl deploy-exp-core; cpl deploy-exp-query;", "deploy-exp": "cpl deploy-exp-cli; cpl deploy-exp-core; cpl deploy-exp-query;",
"de": "cpl deploy-exp $ARGS", "de": "cpl deploy-exp $ARGS",
"deploy-exp-cli": "cpl publish-cli; cpl upload-exp-cli", "deploy-exp-cli": "cpl publish-cli; cpl upload-exp-cli",
"deploy-exp-core": "cpl publish-core; cpl upload-exp-core", "deploy-exp-core": "cpl publish-core; cpl upload-exp-core",
"deploy-exp-query": "cpl publish-query; cpl upload-exp-query", "deploy-exp-query": "cpl publish-query; cpl upload-exp-query",
"pre-deploy-dev": "cpl sv $ARGS; cpl spu --environment=development;", "pre-deploy-dev": "cpl sv $ARGS; cpl spu --environment=development;",
"deploy-dev": "cpl deploy-dev-cli; cpl deploy-dev-core; cpl deploy-dev-query;", "deploy-dev": "cpl deploy-dev-cli; cpl deploy-dev-core; cpl deploy-dev-query;",
"dd": "cpl deploy-dev $ARGS", "dd": "cpl deploy-dev $ARGS",

View File

@ -1,4 +1,3 @@
import time
import unittest import unittest
from cpl_core.application import ApplicationABC from cpl_core.application import ApplicationABC

View File

@ -5,7 +5,7 @@ import unittest
from unittests_cli.add_test_case import AddTestCase from unittests_cli.add_test_case import AddTestCase
from unittests_cli.build_test_case import BuildTestCase from unittests_cli.build_test_case import BuildTestCase
from unittests_cli.constants import PLAYGROUND from unittests_cli.constants import PLAYGROUND_PATH
from unittests_cli.generate_test_case import GenerateTestCase from unittests_cli.generate_test_case import GenerateTestCase
from unittests_cli.install_test_case import InstallTestCase from unittests_cli.install_test_case import InstallTestCase
from unittests_cli.new_test_case import NewTestCase from unittests_cli.new_test_case import NewTestCase
@ -45,19 +45,19 @@ class CLITestSuite(unittest.TestSuite):
def _setup(self): def _setup(self):
print(f'Setup {__name__}') print(f'Setup {__name__}')
try: try:
if os.path.exists(PLAYGROUND): if os.path.exists(PLAYGROUND_PATH):
shutil.rmtree(PLAYGROUND) shutil.rmtree(PLAYGROUND_PATH)
os.mkdir(PLAYGROUND) os.mkdir(PLAYGROUND_PATH)
os.chdir(PLAYGROUND) os.chdir(PLAYGROUND_PATH)
except Exception as e: except Exception as e:
print(f'Setup of {__name__} failed: {traceback.format_exc()}') print(f'Setup of {__name__} failed: {traceback.format_exc()}')
def _cleanup(self): def _cleanup(self):
print(f'Cleanup {__name__}') print(f'Cleanup {__name__}')
try: try:
if os.path.exists(PLAYGROUND): if os.path.exists(PLAYGROUND_PATH):
shutil.rmtree(PLAYGROUND) shutil.rmtree(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()}')

View File

@ -1,3 +1,4 @@
import os import os
PLAYGROUND = os.path.abspath(os.path.join(os.getcwd(), '../generated/test_cli_playground')) PLAYGROUND_PATH = os.path.abspath(os.path.join(os.getcwd(), '../generated/test_cli_playground'))
CLI_PATH = os.path.abspath(os.path.join(os.getcwd(), '../../cpl_cli/main.py'))

View File

@ -1,18 +1,15 @@
import os.path import os.path
import unittest import unittest
from unittests_cli.constants import PLAYGROUND from unittests_cli.constants import PLAYGROUND_PATH
from unittests_shared.cli_commands import CLICommands from unittests_shared.cli_commands import CLICommands
class GenerateTestCase(unittest.TestCase): class GenerateTestCase(unittest.TestCase):
def setUp(self):
pass
def _test_file(self, schematic: str, suffix: str): def _test_file(self, schematic: str, suffix: str):
CLICommands.generate(schematic, 'GeneratedFile') CLICommands.generate(schematic, 'GeneratedFile')
file_path = os.path.abspath(os.path.join(PLAYGROUND, f'generated_file{suffix}.py')) file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, f'generated_file{suffix}.py'))
file_exists = os.path.exists(file_path) file_exists = os.path.exists(file_path)
self.assertTrue(file_exists) self.assertTrue(file_exists)
os.remove(file_path) os.remove(file_path)

View File

@ -1,13 +1,15 @@
import os import os
import subprocess import subprocess
from unittests_cli.constants import CLI_PATH
class CLICommands: class CLICommands:
@staticmethod @staticmethod
def _run(cmd: str, *args): def _run(cmd: str, *args):
env_vars = os.environ env_vars = os.environ
command = ['python', os.path.abspath(os.path.join(os.getcwd(), '../../../cpl_cli/main.py')), cmd] command = ['python', CLI_PATH, cmd]
for arg in args: for arg in args:
command.append(arg) command.append(arg)