Updated docs

This commit is contained in:
2023-02-20 15:55:20 +01:00
parent 48d0daabf5
commit 9e28dce5ce
632 changed files with 10917 additions and 6775 deletions

View File

@@ -12,13 +12,12 @@ from unittests_shared.cli_commands import CLICommands
class StartTestCase(CommandTestCase):
def __init__(self, method_name: str):
CommandTestCase.__init__(self, method_name)
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._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
import os
@@ -40,11 +39,11 @@ class StartTestCase(CommandTestCase):
"""
def _get_appsettings(self, is_dev=False):
appsettings = f'dist/{self._source}/build/{String.convert_to_snake_case(self._source)}/appsettings.json'
appsettings = f"dist/{self._source}/build/{String.convert_to_snake_case(self._source)}/appsettings.json"
if is_dev:
appsettings = f'src/{String.convert_to_snake_case(self._source)}/appsettings.json'
appsettings = f"src/{String.convert_to_snake_case(self._source)}/appsettings.json"
with open(os.path.join(os.getcwd(), appsettings), 'r', encoding='utf-8') as cfg:
with open(os.path.join(os.getcwd(), appsettings), "r", encoding="utf-8") as cfg:
# load json
project_json = json.load(cfg)
cfg.close()
@@ -52,7 +51,11 @@ class StartTestCase(CommandTestCase):
return project_json
def _save_appsettings(self, settings: dict):
with open(os.path.join(os.getcwd(), f'src/{String.convert_to_snake_case(self._source)}/appsettings.json'), 'w', encoding='utf-8') as project_file:
with open(
os.path.join(os.getcwd(), f"src/{String.convert_to_snake_case(self._source)}/appsettings.json"),
"w",
encoding="utf-8",
) as project_file:
project_file.write(json.dumps(settings, indent=2))
project_file.close()
@@ -62,12 +65,12 @@ class StartTestCase(CommandTestCase):
os.chdir(PLAYGROUND_PATH)
# create projects
CLICommands.new('console', self._source, '--ab', '--s')
CLICommands.new("console", self._source, "--ab", "--s")
os.chdir(os.path.join(os.getcwd(), self._source))
settings = {'RunTest': {'WasStarted': 'False', 'WasRestarted': 'False'}}
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}')
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 test_start(self):
@@ -76,32 +79,23 @@ class StartTestCase(CommandTestCase):
time.sleep(5)
settings = self._get_appsettings()
self.assertNotEqual(settings, {})
self.assertIn('RunTest', settings)
self.assertIn('WasStarted', settings['RunTest'])
self.assertEqual(
'True',
settings['RunTest']['WasStarted']
)
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)')
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(5)
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']
)
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"])
def test_start_dev(self):
thread = StartTestThread(is_dev=True)
@@ -109,29 +103,20 @@ class StartTestCase(CommandTestCase):
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']
)
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)')
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(is_dev=True)
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']
)
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"])