Fixed cpl g path problems & package names #93
This commit is contained in:
		| @@ -78,7 +78,7 @@ class BuildTestCase(unittest.TestCase): | ||||
|     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)}' | ||||
|         full_dist_path = f'{dist_path}/{self._source}/build/' | ||||
|         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)) | ||||
|   | ||||
| @@ -32,8 +32,8 @@ class CLITestSuite(unittest.TestSuite): | ||||
|         active_tests = [ | ||||
|             # nothing needed | ||||
|             VersionTestCase, | ||||
|             GenerateTestCase, | ||||
|             NewTestCase, | ||||
|             GenerateTestCase, | ||||
|             # project needed | ||||
|             BuildTestCase, | ||||
|             PublishTestCase, | ||||
| @@ -75,4 +75,4 @@ class CLITestSuite(unittest.TestSuite): | ||||
|     def run(self, *args): | ||||
|         self._setup() | ||||
|         self._result = super().run(*args) | ||||
|         self._cleanup() | ||||
|         # self._cleanup() | ||||
|   | ||||
| @@ -1,41 +1,89 @@ | ||||
| import os.path | ||||
| import unittest | ||||
|  | ||||
| from cpl_core.utils import String | ||||
| from unittests_cli.constants import PLAYGROUND_PATH | ||||
| from unittests_shared.cli_commands import CLICommands | ||||
|  | ||||
|  | ||||
| class GenerateTestCase(unittest.TestCase): | ||||
|     _project = 'test-console' | ||||
|     _t_path = 'test' | ||||
|  | ||||
|     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')) | ||||
|     @classmethod | ||||
|     def setUpClass(cls): | ||||
|         CLICommands.new('console', cls._project, '--ab', '--s', '--venv') | ||||
|  | ||||
|     def setUp(self): | ||||
|         os.chdir(PLAYGROUND_PATH) | ||||
|  | ||||
|     def _test_file(self, schematic: str, suffix: str, path=None): | ||||
|         file = 'GeneratedFile' | ||||
|         expected_path = f'generated_file{suffix}.py' | ||||
|         if path is not None: | ||||
|             file = f'{path}/{file}' | ||||
|             expected_path = f'{path}/{expected_path}' | ||||
|         CLICommands.generate(schematic, file) | ||||
|         file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, expected_path)) | ||||
|         file_exists = os.path.exists(file_path) | ||||
|         self.assertTrue(file_exists) | ||||
|  | ||||
|     def _test_file_with_project(self, schematic: str, suffix: str, path=None, enter=True): | ||||
|         file = f'GeneratedFile' | ||||
|         excepted_path = f'generated_file{suffix}.py' | ||||
|         if path is not None: | ||||
|             excepted_path = f'{self._project}/src/{String.convert_to_snake_case(self._project)}/{path}/generated_file_in_project{suffix}.py' | ||||
|             if enter: | ||||
|                 os.chdir(path) | ||||
|                 excepted_path = f'{path}/src/{String.convert_to_snake_case(self._project)}/generated_file_in_project{suffix}.py' | ||||
|  | ||||
|             file = f'{path}/GeneratedFileInProject' | ||||
|  | ||||
|         CLICommands.generate(schematic, file) | ||||
|         file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, excepted_path)) | ||||
|         self.assertTrue(os.path.exists(file_path)) | ||||
|  | ||||
|     def test_abc(self): | ||||
|         self._test_file('abc', '_abc') | ||||
|         self._test_file('abc', '_abc', path=self._t_path) | ||||
|         self._test_file('abc', '_abc', path=f'{self._t_path}/{self._t_path}') | ||||
|         self._test_file_with_project('abc', '_abc', path=self._project) | ||||
|         os.chdir(f'src/{String.convert_to_snake_case(self._project)}') | ||||
|         self._test_file_with_project('abc', '_abc', path='test', enter=False) | ||||
|  | ||||
|     def test_class(self): | ||||
|         self._test_file('class', '') | ||||
|         self._test_file('class', '', path=self._t_path) | ||||
|         self._test_file_with_project('class', '', path=self._project) | ||||
|  | ||||
|     def test_enum(self): | ||||
|         self._test_file('enum', '_enum') | ||||
|         self._test_file('enum', '_enum', path=self._t_path) | ||||
|         self._test_file_with_project('enum', '_enum', path=self._project) | ||||
|         os.chdir(f'src/{String.convert_to_snake_case(self._project)}') | ||||
|         self._test_file_with_project('enum', '_enum', path='test', enter=False) | ||||
|  | ||||
|     def test_pipe(self): | ||||
|         self._test_file('pipe', '_pipe') | ||||
|         self._test_file('pipe', '_pipe', path=self._t_path) | ||||
|         self._test_file_with_project('pipe', '_pipe', path=self._project) | ||||
|  | ||||
|     def test_service(self): | ||||
|         self._test_file('service', '_service') | ||||
|         self._test_file_with_project('service', '_service', path=self._project) | ||||
|  | ||||
|     def test_settings(self): | ||||
|         self._test_file('settings', '_settings') | ||||
|         self._test_file_with_project('settings', '_settings', path=self._project) | ||||
|  | ||||
|     def test_test_case(self): | ||||
|         self._test_file('test_case', '_test_case') | ||||
|         self._test_file_with_project('test_case', '_test_case', path=self._project) | ||||
|  | ||||
|     def test_thread(self): | ||||
|         self._test_file('thread', '_thread') | ||||
|         self._test_file_with_project('thread', '_thread', path=self._project) | ||||
|  | ||||
|     def test_validator(self): | ||||
|         self._test_file('validator', '_validator') | ||||
|         self._test_file_with_project('validator', '_validator', path=self._project) | ||||
|   | ||||
| @@ -79,7 +79,7 @@ class PublishTestCase(unittest.TestCase): | ||||
|         CLICommands.publish() | ||||
|         dist_path = './dist' | ||||
|         setup_path = f'{dist_path}/{self._source}/publish/setup' | ||||
|         full_dist_path = f'{dist_path}/{self._source}/publish/build/lib/{String.convert_to_snake_case(self._source)}' | ||||
|         full_dist_path = f'{dist_path}/{self._source}/publish/' | ||||
|         self.assertTrue(os.path.exists(dist_path)) | ||||
|         self.assertTrue(os.path.exists(setup_path)) | ||||
|         self.assertTrue(os.path.exists(os.path.join(setup_path, f'{self._source}-0.0.0.tar.gz'))) | ||||
| @@ -89,4 +89,4 @@ class PublishTestCase(unittest.TestCase): | ||||
|         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)) | ||||
|   | ||||
| @@ -22,7 +22,7 @@ class UpdateTestCase(unittest.TestCase): | ||||
|         self._old_package = f'{self._old_package_name}=={self._old_version}' | ||||
|  | ||||
|         # todo: better way to do shit required | ||||
|         self._new_version = '2.0.1' | ||||
|         self._new_version = '2.1.0' | ||||
|         self._new_package_name = 'discord.py' | ||||
|         self._new_package = f'{self._new_package_name}=={self._new_version}' | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user