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

@@ -10,14 +10,13 @@ from unittests_shared.cli_commands import CLICommands
class BuildTestCase(CommandTestCase):
def __init__(self, method_name: str):
CommandTestCase.__init__(self, method_name)
self._source = 'build-test-source'
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
self._source = "build-test-source"
self._project_file = f"src/{String.convert_to_snake_case(self._source)}/{self._source}.json"
def _get_project_settings(self):
with open(os.path.join(os.getcwd(), self._project_file), 'r', encoding='utf-8') as cfg:
with open(os.path.join(os.getcwd(), self._project_file), "r", encoding="utf-8") as cfg:
# load json
project_json = json.load(cfg)
cfg.close()
@@ -25,17 +24,17 @@ class BuildTestCase(CommandTestCase):
return project_json
def _save_project_settings(self, settings: dict):
with open(os.path.join(os.getcwd(), self._project_file), 'w', encoding='utf-8') as project_file:
with open(os.path.join(os.getcwd(), self._project_file), "w", encoding="utf-8") as project_file:
project_file.write(json.dumps(settings, indent=2))
project_file.close()
def setUp(self):
if not os.path.exists(PLAYGROUND_PATH):
os.makedirs(PLAYGROUND_PATH)
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))
def _are_dir_trees_equal(self, dir1, dir2):
@@ -51,7 +50,7 @@ class BuildTestCase(CommandTestCase):
@return: True if the directory trees are the same and
there were no errors while accessing the directories or files,
False otherwise.
"""
"""
dirs_cmp = filecmp.dircmp(dir1, dir2)
if len(dirs_cmp.left_only) > 0 or len(dirs_cmp.right_only) > 0 or len(dirs_cmp.funny_files) > 0:
@@ -72,12 +71,16 @@ class BuildTestCase(CommandTestCase):
def test_build(self):
CLICommands.build()
dist_path = './dist'
full_dist_path = f'{dist_path}/{self._source}/build/{String.convert_to_snake_case(self._source)}'
dist_path = "./dist"
full_dist_path = f"{dist_path}/{self._source}/build/{String.convert_to_snake_case(self._source)}"
self.assertTrue(os.path.exists(dist_path))
self.assertTrue(os.path.exists(full_dist_path))
self.assertFalse(self._are_dir_trees_equal(f'./src/{String.convert_to_snake_case(self._source)}', full_dist_path))
with open(f'{full_dist_path}/{self._source}.json', 'w') as file:
self.assertFalse(
self._are_dir_trees_equal(f"./src/{String.convert_to_snake_case(self._source)}", full_dist_path)
)
with open(f"{full_dist_path}/{self._source}.json", "w") as file:
file.write(json.dumps(self._get_project_settings(), indent=2))
file.close()
self.assertTrue(self._are_dir_trees_equal(f'./src/{String.convert_to_snake_case(self._source)}', full_dist_path))
self.assertTrue(
self._are_dir_trees_equal(f"./src/{String.convert_to_snake_case(self._source)}", full_dist_path)
)