Compare commits
No commits in common. "78ffbcc33dabdf6dcf344c826d320696f5c15746" and "6e50d0cb228f13fa44f01c6dfccf14f5c06fbc2f" have entirely different histories.
78ffbcc33d
...
6e50d0cb22
@ -13,8 +13,6 @@ from unittests_cli.install_test_case import InstallTestCase
|
|||||||
from unittests_cli.new_test_case import NewTestCase
|
from unittests_cli.new_test_case import NewTestCase
|
||||||
from unittests_cli.publish_test_case import PublishTestCase
|
from unittests_cli.publish_test_case import PublishTestCase
|
||||||
from unittests_cli.remove_test_case import RemoveTestCase
|
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.uninstall_test_case import UninstallTestCase
|
||||||
from unittests_cli.update_test_case import UpdateTestCase
|
from unittests_cli.update_test_case import UpdateTestCase
|
||||||
|
|
||||||
@ -26,7 +24,6 @@ class CLITestSuite(unittest.TestSuite):
|
|||||||
|
|
||||||
loader = unittest.TestLoader()
|
loader = unittest.TestLoader()
|
||||||
self._result: Optional[TestResult] = None
|
self._result: Optional[TestResult] = None
|
||||||
self._is_online = True
|
|
||||||
|
|
||||||
active_tests = [
|
active_tests = [
|
||||||
# nothing needed
|
# nothing needed
|
||||||
@ -36,9 +33,13 @@ class CLITestSuite(unittest.TestSuite):
|
|||||||
# VersionTestCase,
|
# VersionTestCase,
|
||||||
# project needed
|
# project needed
|
||||||
BuildTestCase,
|
BuildTestCase,
|
||||||
|
InstallTestCase,
|
||||||
PublishTestCase,
|
PublishTestCase,
|
||||||
RunTestCase,
|
# check if application was executed properly
|
||||||
StartTestCase,
|
# RunTestCase,
|
||||||
|
# check if application was executed properly and file watcher is working
|
||||||
|
# StartTestCase,
|
||||||
|
UninstallTestCase,
|
||||||
# check in project settings if package is updated
|
# check in project settings if package is updated
|
||||||
# UpdateTestCase,
|
# UpdateTestCase,
|
||||||
# workspace needed
|
# workspace needed
|
||||||
@ -46,10 +47,6 @@ class CLITestSuite(unittest.TestSuite):
|
|||||||
RemoveTestCase
|
RemoveTestCase
|
||||||
]
|
]
|
||||||
|
|
||||||
if self._is_online:
|
|
||||||
active_tests.append(InstallTestCase)
|
|
||||||
active_tests.append(UninstallTestCase)
|
|
||||||
|
|
||||||
for test in active_tests:
|
for test in active_tests:
|
||||||
self.addTests(loader.loadTestsFromTestCase(test))
|
self.addTests(loader.loadTestsFromTestCase(test))
|
||||||
|
|
||||||
|
@ -5,7 +5,10 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
from cpl_core.utils import String
|
from cpl_core.utils import String
|
||||||
|
|
||||||
from unittests_cli.constants import PLAYGROUND_PATH
|
from unittests_cli.constants import PLAYGROUND_PATH
|
||||||
from unittests_shared.cli_commands import CLICommands
|
from unittests_shared.cli_commands import CLICommands
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from cpl_core.utils import String
|
from cpl_core.utils import String
|
||||||
|
|
||||||
from unittests_cli.constants import PLAYGROUND_PATH
|
from unittests_cli.constants import PLAYGROUND_PATH
|
||||||
from unittests_shared.cli_commands import CLICommands
|
from unittests_shared.cli_commands import CLICommands
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from cpl_core.utils import String
|
from cpl_core.utils import String
|
||||||
|
|
||||||
from unittests_cli.constants import PLAYGROUND_PATH
|
from unittests_cli.constants import PLAYGROUND_PATH
|
||||||
from unittests_shared.cli_commands import CLICommands
|
from unittests_shared.cli_commands import CLICommands
|
||||||
|
|
||||||
|
@ -1,91 +1,10 @@
|
|||||||
import json
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
|
|
||||||
from cpl_core.utils import String
|
|
||||||
|
|
||||||
from unittests_cli.constants import PLAYGROUND_PATH
|
|
||||||
from unittests_shared.cli_commands import CLICommands
|
|
||||||
|
|
||||||
|
|
||||||
class RunTestCase(unittest.TestCase):
|
class RunTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def __init__(self, methodName: str):
|
|
||||||
unittest.TestCase.__init__(self, methodName)
|
|
||||||
self._source = 'run-test'
|
|
||||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
|
||||||
self._appsettings = f'src/{String.convert_to_snake_case(self._source)}/appsettings.json'
|
|
||||||
self._application = f'src/{String.convert_to_snake_case(self._source)}/application.py'
|
|
||||||
self._test_code = f"""
|
|
||||||
import json
|
|
||||||
settings = dict()
|
|
||||||
with open('appsettings.json', 'r', encoding='utf-8') as cfg:
|
|
||||||
# load json
|
|
||||||
settings = json.load(cfg)
|
|
||||||
cfg.close()
|
|
||||||
|
|
||||||
settings['RunTest']['WasStarted'] = 'True'
|
|
||||||
|
|
||||||
with open('appsettings.json', 'w', encoding='utf-8') as project_file:
|
|
||||||
project_file.write(json.dumps(settings, indent=2))
|
|
||||||
project_file.close()
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _get_appsettings(self):
|
|
||||||
with open(os.path.join(os.getcwd(), self._appsettings), 'r', encoding='utf-8') as cfg:
|
|
||||||
# load json
|
|
||||||
project_json = json.load(cfg)
|
|
||||||
cfg.close()
|
|
||||||
|
|
||||||
return project_json
|
|
||||||
|
|
||||||
def _save_appsettings(self, settings: dict):
|
|
||||||
with open(os.path.join(os.getcwd(), self._appsettings), 'w', encoding='utf-8') as project_file:
|
|
||||||
project_file.write(json.dumps(settings, indent=2))
|
|
||||||
project_file.close()
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
os.chdir(os.path.abspath(PLAYGROUND_PATH))
|
pass
|
||||||
# create projects
|
|
||||||
CLICommands.new('console', self._source, '--ab', '--s')
|
|
||||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
|
||||||
settings = {'RunTest': {'WasStarted': 'False'}}
|
|
||||||
self._save_appsettings(settings)
|
|
||||||
with open(os.path.join(os.getcwd(), self._application), 'a', encoding='utf-8') as file:
|
|
||||||
file.write(f'\t\t{self._test_code}')
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
def cleanUp(self):
|
def test_equal(self):
|
||||||
# remove projects
|
pass
|
||||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
|
||||||
return
|
|
||||||
|
|
||||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
|
||||||
|
|
||||||
def test_run(self):
|
|
||||||
CLICommands.run()
|
|
||||||
settings = self._get_appsettings()
|
|
||||||
self.assertNotEqual(settings, {})
|
|
||||||
self.assertIn('RunTest', settings)
|
|
||||||
self.assertIn('WasStarted', settings['RunTest'])
|
|
||||||
self.assertEqual(
|
|
||||||
'True',
|
|
||||||
settings['RunTest']['WasStarted']
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_run_by_project(self):
|
|
||||||
os.chdir(os.path.join(os.getcwd()))
|
|
||||||
CLICommands.run(self._source)
|
|
||||||
settings = self._get_appsettings()
|
|
||||||
self.assertNotEqual(settings, {})
|
|
||||||
self.assertIn('RunTest', settings)
|
|
||||||
self.assertIn('WasStarted', settings['RunTest'])
|
|
||||||
self.assertEqual(
|
|
||||||
'True',
|
|
||||||
settings['RunTest']['WasStarted']
|
|
||||||
)
|
|
||||||
|
@ -1,101 +1,10 @@
|
|||||||
import json
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import time
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from cpl_core.utils import String
|
|
||||||
from unittests_cli.constants import PLAYGROUND_PATH
|
|
||||||
from unittests_cli.threads.start_test_thread import StartTestThread
|
|
||||||
from unittests_shared.cli_commands import CLICommands
|
|
||||||
|
|
||||||
|
|
||||||
class StartTestCase(unittest.TestCase):
|
class StartTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def __init__(self, methodName: str):
|
|
||||||
unittest.TestCase.__init__(self, methodName)
|
|
||||||
self._source = 'start-test'
|
|
||||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
|
||||||
self._appsettings = f'src/{String.convert_to_snake_case(self._source)}/appsettings.json'
|
|
||||||
self._application = f'src/{String.convert_to_snake_case(self._source)}/application.py'
|
|
||||||
self._test_code = f"""
|
|
||||||
import json
|
|
||||||
settings = dict()
|
|
||||||
with open('appsettings.json', 'r', encoding='utf-8') as cfg:
|
|
||||||
# load json
|
|
||||||
settings = json.load(cfg)
|
|
||||||
cfg.close()
|
|
||||||
|
|
||||||
if settings['RunTest']['WasStarted'] == 'True':
|
|
||||||
settings['RunTest']['WasRestarted'] = 'True'
|
|
||||||
|
|
||||||
settings['RunTest']['WasStarted'] = 'True'
|
|
||||||
|
|
||||||
with open('appsettings.json', 'w', encoding='utf-8') as project_file:
|
|
||||||
project_file.write(json.dumps(settings, indent=2))
|
|
||||||
project_file.close()
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _get_appsettings(self):
|
|
||||||
with open(os.path.join(os.getcwd(), self._appsettings), 'r', encoding='utf-8') as cfg:
|
|
||||||
# load json
|
|
||||||
project_json = json.load(cfg)
|
|
||||||
cfg.close()
|
|
||||||
|
|
||||||
return project_json
|
|
||||||
|
|
||||||
def _save_appsettings(self, settings: dict):
|
|
||||||
with open(os.path.join(os.getcwd(), self._appsettings), 'w', encoding='utf-8') as project_file:
|
|
||||||
project_file.write(json.dumps(settings, indent=2))
|
|
||||||
project_file.close()
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
os.chdir(os.path.abspath(PLAYGROUND_PATH))
|
pass
|
||||||
# create projects
|
|
||||||
CLICommands.new('console', self._source, '--ab', '--s')
|
|
||||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
|
||||||
settings = {'RunTest': {'WasStarted': 'False', 'WasRestarted': 'False'}}
|
|
||||||
self._save_appsettings(settings)
|
|
||||||
with open(os.path.join(os.getcwd(), self._application), 'a', encoding='utf-8') as file:
|
|
||||||
file.write(f'\t\t{self._test_code}')
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
def cleanUp(self):
|
def test_equal(self):
|
||||||
# remove projects
|
pass
|
||||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
|
||||||
return
|
|
||||||
|
|
||||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
|
||||||
|
|
||||||
def test_start(self):
|
|
||||||
thread = StartTestThread()
|
|
||||||
thread.start()
|
|
||||||
time.sleep(1)
|
|
||||||
settings = self._get_appsettings()
|
|
||||||
self.assertNotEqual(settings, {})
|
|
||||||
self.assertIn('RunTest', settings)
|
|
||||||
self.assertIn('WasStarted', settings['RunTest'])
|
|
||||||
self.assertEqual(
|
|
||||||
'True',
|
|
||||||
settings['RunTest']['WasStarted']
|
|
||||||
)
|
|
||||||
|
|
||||||
with open(os.path.join(os.getcwd(), self._application), 'a', encoding='utf-8') as file:
|
|
||||||
file.write(f'# trigger restart (comment generated by unittest)')
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
settings = self._get_appsettings()
|
|
||||||
self.assertNotEqual(settings, {})
|
|
||||||
self.assertIn('RunTest', settings)
|
|
||||||
self.assertIn('WasStarted', settings['RunTest'])
|
|
||||||
self.assertIn('WasRestarted', settings['RunTest'])
|
|
||||||
self.assertEqual(
|
|
||||||
'True',
|
|
||||||
settings['RunTest']['WasStarted']
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
'True',
|
|
||||||
settings['RunTest']['WasRestarted']
|
|
||||||
)
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
# imports
|
|
@ -1,12 +0,0 @@
|
|||||||
import threading
|
|
||||||
|
|
||||||
from unittests_shared.cli_commands import CLICommands
|
|
||||||
|
|
||||||
|
|
||||||
class StartTestThread(threading.Thread):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
threading.Thread.__init__(self, daemon=True)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
CLICommands.start(True)
|
|
@ -15,18 +15,15 @@ class CLICommands:
|
|||||||
for arg in args:
|
for arg in args:
|
||||||
command.append(arg)
|
command.append(arg)
|
||||||
|
|
||||||
if output:
|
subprocess.run(command, env=env_vars)
|
||||||
subprocess.run(command, env=env_vars)
|
|
||||||
else:
|
|
||||||
subprocess.run(command, env=env_vars, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add(cls, source: str, target: str, output=False):
|
def add(cls, source: str, target: str):
|
||||||
cls._run('add', source, target, output=output)
|
cls._run('add', source, target)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def build(cls, output=False):
|
def build(cls):
|
||||||
cls._run('build', output=output)
|
cls._run('build')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls, schematic: str, name: str, output=False):
|
def generate(cls, schematic: str, name: str, output=False):
|
||||||
@ -45,23 +42,12 @@ class CLICommands:
|
|||||||
cls._run('new', project_type, name, *args, output=output)
|
cls._run('new', project_type, name, *args, output=output)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def publish(cls, output=False):
|
def publish(cls):
|
||||||
cls._run('publish', output=output)
|
cls._run('publish')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def remove(cls, project: str, output=False):
|
def remove(cls, project: str):
|
||||||
cls._run('remove', project, output=output)
|
cls._run('remove', project)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def run(cls, project: str = None, output=False):
|
|
||||||
if project is None:
|
|
||||||
cls._run('run', output=output)
|
|
||||||
return
|
|
||||||
cls._run('run', project, output=output)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def start(cls, output=False):
|
|
||||||
cls._run('start', output=output)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def uninstall(cls, package: str, output=False):
|
def uninstall(cls, package: str, output=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user