16 Commits

Author SHA1 Message Date
ba1b5e49ae Merge pull request 'Added logic to change base path for cpl n #120' (#128) from #120 into 2022.12
Reviewed-on: #128
Closes #120
2022-12-01 14:00:46 +01:00
703a2c91b5 Added logic to change base path for cpl n #120 2022-12-01 13:55:55 +01:00
4a54bb62de Merge pull request 'cpl g in project directory #93' (#127) from #93 into 2022.12
Reviewed-on: #127
Closes #93
2022-12-01 12:26:01 +01:00
9e84c8359b Removed empty PythonPath #93 2022-12-01 12:25:36 +01:00
5139876d90 Merge branch '#93' of https://git.sh-edraft.de/sh-edraft.de/sh_cpl into #93 2022-12-01 12:22:20 +01:00
6aef49de40 Repaired build & publish #93 2022-12-01 12:22:14 +01:00
186b336bf3 Repaired build & publish #93 2022-12-01 12:22:14 +01:00
1bbec27d1a Fixed cpl g path problems & package names #93 2022-12-01 12:21:57 +01:00
f0a8d69e22 Merge branch '2022.12' of https://git.sh-edraft.de/sh-edraft.de/sh_cpl into 2022.12 2022-12-01 12:21:17 +01:00
8bd237206c Fixed logging #123 2022-12-01 12:20:32 +01:00
2e8be741cc Repaired build & publish #93 2022-12-01 12:17:26 +01:00
abd0352750 Repaired build & publish #93 2022-11-30 19:05:11 +01:00
25d91b85f3 Merge branch '2022.12' into #93 2022-11-30 18:06:49 +01:00
f08eb42105 Merge pull request 'Logging Farben #123' (#126) from #123 into 2022.12
Reviewed-on: #126
Closes #123
2022-11-30 18:06:12 +01:00
f450102c93 Fixed cpl g path problems & package names #93 2022-11-30 18:04:40 +01:00
db28645e98 Fixed logging #123 2022-11-30 15:17:08 +01:00
31 changed files with 154 additions and 101 deletions

View File

@@ -131,7 +131,15 @@
"di-cli": "pip install cpl-cli --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de", "di-cli": "pip install cpl-cli --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de",
"di-discord": "pip install cpl-discord --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de", "di-discord": "pip install cpl-discord --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de",
"di-query": "pip install cpl-query --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de", "di-query": "pip install cpl-query --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de",
"di-translation": "pip install cpl-translation --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de" "di-translation": "pip install cpl-translation --pre --upgrade --extra-index-url https://pip-dev.sh-edraft.de",
"prod-install": "cpl pi-core; cpl pi-cli; cpl pi-query; cpl pi-translation;",
"pi": "cpl prod-install",
"pi-core": "pip install cpl-core --pre --upgrade --extra-index-url https://pip.sh-edraft.de",
"pi-cli": "pip install cpl-cli --pre --upgrade --extra-index-url https://pip.sh-edraft.de",
"pi-discord": "pip install cpl-discord --pre --upgrade --extra-index-url https://pip.sh-edraft.de",
"pi-query": "pip install cpl-query --pre --upgrade --extra-index-url https://pip.sh-edraft.de",
"pi-translation": "pip install cpl-translation --pre --upgrade --extra-index-url https://pip.sh-edraft.de"
} }
} }
} }

View File

@@ -14,6 +14,7 @@ from cpl_cli._templates.generate.thread_template import ThreadTemplate
from cpl_cli._templates.generate.validator_template import ValidatorTemplate from cpl_cli._templates.generate.validator_template import ValidatorTemplate
from cpl_cli._templates.template_file_abc import TemplateFileABC from cpl_cli._templates.template_file_abc import TemplateFileABC
from cpl_cli.command_abc import CommandABC from cpl_cli.command_abc import CommandABC
from cpl_cli.configuration import WorkspaceSettings
from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.configuration.configuration_abc import ConfigurationABC
from cpl_core.console.console import Console from cpl_core.console.console import Console
from cpl_core.console.foreground_color_enum import ForegroundColorEnum from cpl_core.console.foreground_color_enum import ForegroundColorEnum
@@ -22,13 +23,20 @@ from cpl_core.utils.string import String
class GenerateService(CommandABC): class GenerateService(CommandABC):
def __init__(self, configuration: ConfigurationABC): def __init__(
self,
configuration: ConfigurationABC,
workspace: WorkspaceSettings,
):
""" """
Service for the CLI command generate Service for the CLI command generate
:param configuration: :param configuration:
""" """
CommandABC.__init__(self) CommandABC.__init__(self)
self._config = configuration
self._workspace = workspace
self._schematics = { self._schematics = {
"abc": { "abc": {
"Upper": "ABC", "Upper": "ABC",
@@ -129,27 +137,7 @@ class GenerateService(CommandABC):
template.write(value) template.write(value)
template.close() template.close()
def _generate(self, schematic: str, name: str, template: TemplateFileABC): def _create_init_files(self, file_path: str, template: TemplateFileABC, class_name: str, schematic: str, rel_path: str):
"""
Generates files by given schematic, name and template
:param schematic:
:param name:
:param template:
:return:
"""
class_name = name
rel_path = ''
if '/' in name:
parts = name.split('/')
rel_path = '/'.join(parts[:-1])
class_name = parts[len(parts) - 1]
if 'src' not in rel_path and not os.path.exists(os.path.join(self._env.working_directory, rel_path)):
rel_path = f'src/{rel_path}'
template = template(class_name, schematic, self._schematics[schematic]["Upper"], rel_path)
file_path = os.path.join(self._env.working_directory, template.path, template.name)
if not os.path.isdir(os.path.dirname(file_path)): if not os.path.isdir(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path)) os.makedirs(os.path.dirname(file_path))
directory = '' directory = ''
@@ -171,6 +159,29 @@ class GenerateService(CommandABC):
spinner_foreground_color=ForegroundColorEnum.cyan spinner_foreground_color=ForegroundColorEnum.cyan
) )
def _generate(self, schematic: str, name: str, template: TemplateFileABC):
"""
Generates files by given schematic, name and template
:param schematic:
:param name:
:param template:
:return:
"""
class_name = name
rel_path = ''
if '/' in name:
parts = name.split('/')
rel_path = '/'.join(parts[:-1])
class_name = parts[len(parts) - 1]
if self._workspace is not None and parts[0] in self._workspace.projects:
rel_path = os.path.dirname(self._workspace.projects[parts[0]])
template = template(class_name, schematic, self._schematics[schematic]["Upper"], rel_path)
file_path = os.path.join(self._env.working_directory, template.path, template.name)
self._create_init_files(file_path, template, class_name, schematic, rel_path)
if os.path.isfile(file_path): if os.path.isfile(file_path):
Console.error(f'{String.first_to_upper(schematic)} already exists!\n') Console.error(f'{String.first_to_upper(schematic)} already exists!\n')
sys.exit() sys.exit()

View File

@@ -54,6 +54,7 @@ class NewService(CommandABC):
self._use_service_providing: bool = False self._use_service_providing: bool = False
self._use_async: bool = False self._use_async: bool = False
self._use_venv: bool = False self._use_venv: bool = False
self._use_base: bool = False
@property @property
def help_message(self) -> str: def help_message(self) -> str:
@@ -159,7 +160,8 @@ class NewService(CommandABC):
if self._workspace is None: if self._workspace is None:
project_path = os.path.join(self._env.working_directory, self._rel_path, self._project.name) project_path = os.path.join(self._env.working_directory, self._rel_path, self._project.name)
else: else:
project_path = os.path.join(self._env.working_directory, 'src', self._rel_path, String.convert_to_snake_case(self._project.name)) base = '' if self._use_base else 'src'
project_path = os.path.join(self._env.working_directory, base, self._rel_path, String.convert_to_snake_case(self._project.name))
if os.path.isdir(project_path) and len(os.listdir(project_path)) > 0: if os.path.isdir(project_path) and len(os.listdir(project_path)) > 0:
Console.write_line(project_path) Console.write_line(project_path)
@@ -292,6 +294,9 @@ class NewService(CommandABC):
if self._env.working_directory.endswith(project): if self._env.working_directory.endswith(project):
project = '' project = ''
if self._workspace is None and self._use_base:
project = f'{self._rel_path}/{project}'
VenvHelper.init_venv( VenvHelper.init_venv(
False, False,
self._env, self._env,
@@ -335,6 +340,9 @@ class NewService(CommandABC):
if 'venv' in args: if 'venv' in args:
self._use_venv = True self._use_venv = True
args.remove('venv') args.remove('venv')
if 'base' in args:
self._use_base = True
args.remove('base')
console = self._config.get_configuration(ProjectTypeEnum.console.value) console = self._config.get_configuration(ProjectTypeEnum.console.value)
library = self._config.get_configuration(ProjectTypeEnum.library.value) library = self._config.get_configuration(ProjectTypeEnum.library.value)

View File

@@ -433,7 +433,7 @@ class PublisherService(PublisherABC):
3. Copies all included source files to dist_path/build 3. Copies all included source files to dist_path/build
:return: :return:
""" """
self._env.set_working_directory(os.path.join(self._env.working_directory, '../')) # probably causing some errors (#125) self._env.set_working_directory(os.path.join(self._env.working_directory, '../')) # probably causing some errors (#125)
self.exclude(f'*/{self._project_settings.name}.json') self.exclude(f'*/{self._project_settings.name}.json')
self._output_path = os.path.abspath(os.path.join(self._output_path, self._project_settings.name, 'build')) self._output_path = os.path.abspath(os.path.join(self._output_path, self._project_settings.name, 'build'))
@@ -456,7 +456,7 @@ class PublisherService(PublisherABC):
4. Remove all included source from dist_path/publish 4. Remove all included source from dist_path/publish
:return: :return:
""" """
self._env.set_working_directory(os.path.join(self._env.working_directory, '../')) # probably causing some errors (#125) self._env.set_working_directory(os.path.join(self._env.working_directory, '../')) # probably causing some errors (#125)
self.exclude(f'*/{self._project_settings.name}.json') self.exclude(f'*/{self._project_settings.name}.json')
self._output_path = os.path.abspath(os.path.join(self._output_path, self._project_settings.name, 'publish')) self._output_path = os.path.abspath(os.path.join(self._output_path, self._project_settings.name, 'publish'))

View File

@@ -55,7 +55,8 @@ class StartupArgumentExtension(StartupExtensionABC):
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'startup', ['s', 'S']) \ .add_console_argument(ArgumentTypeEnum.Flag, '--', 'startup', ['s', 'S']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'service-providing', ['sp', 'SP']) \ .add_console_argument(ArgumentTypeEnum.Flag, '--', 'service-providing', ['sp', 'SP']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'nothing', ['n', 'N']) \ .add_console_argument(ArgumentTypeEnum.Flag, '--', 'nothing', ['n', 'N']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'venv', ['v', 'V']) .add_console_argument(ArgumentTypeEnum.Flag, '--', 'venv', ['v', 'V']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'base', ['b', 'B'])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'publish', ['p', 'P'], PublishService, True, validators=[ProjectValidator]) config.create_console_argument(ArgumentTypeEnum.Executable, '', 'publish', ['p', 'P'], PublishService, True, validators=[ProjectValidator])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'remove', ['r', 'R'], RemoveService, True, validators=[WorkspaceValidator]) \ config.create_console_argument(ArgumentTypeEnum.Executable, '', 'remove', ['r', 'R'], RemoveService, True, validators=[WorkspaceValidator]) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S']) .add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S'])

View File

@@ -169,7 +169,7 @@ class Logger(LoggerABC):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevelEnum.TRACE.value: if self._console.value >= LoggingLevelEnum.TRACE.value:
Console.set_foreground_color(ForegroundColorEnum.green) Console.set_foreground_color(ForegroundColorEnum.grey)
Console.write_line(output) Console.write_line(output)
Console.set_foreground_color(ForegroundColorEnum.default) Console.set_foreground_color(ForegroundColorEnum.default)
@@ -182,7 +182,7 @@ class Logger(LoggerABC):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevelEnum.DEBUG.value: if self._console.value >= LoggingLevelEnum.DEBUG.value:
Console.set_foreground_color(ForegroundColorEnum.green) Console.set_foreground_color(ForegroundColorEnum.blue)
Console.write_line(output) Console.write_line(output)
Console.set_foreground_color(ForegroundColorEnum.default) Console.set_foreground_color(ForegroundColorEnum.default)

View File

@@ -24,9 +24,7 @@
"cpl-cli>=2022.10.0" "cpl-cli>=2022.10.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl>=2021.10.0.post1" "sh_cpl>=2021.10.0.post1"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.2.dev1" "sh_cpl==2021.4.2.dev1"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl>=2021.10.0.post1" "sh_cpl>=2021.10.0.post1"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -22,9 +22,7 @@
"cpl-cli>=2022.7.0" "cpl-cli>=2022.7.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -22,9 +22,7 @@
"cpl-cli>=2022.7.0.post1" "cpl-cli>=2022.7.0.post1"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -22,9 +22,7 @@
"cpl-cli>=2022.6.0" "cpl-cli>=2022.6.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.2" "sh_cpl==2021.4.2"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.1rc2" "sh_cpl==2021.4.1rc2"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.2" "sh_cpl==2021.4.2"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.1rc2" "sh_cpl==2021.4.1rc2"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.2.dev1" "sh_cpl==2021.4.2.dev1"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.1rc2" "sh_cpl==2021.4.1rc2"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.1rc2" "sh_cpl==2021.4.1rc2"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"sh_cpl==2021.4.2" "sh_cpl==2021.4.2"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {

View File

@@ -19,9 +19,7 @@
"cpl-core>=2022.10.0" "cpl-core>=2022.10.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [], "Classifiers": [],
"DevDependencies": [] "DevDependencies": []
}, },

View File

@@ -32,8 +32,8 @@ class CLITestSuite(unittest.TestSuite):
active_tests = [ active_tests = [
# nothing needed # nothing needed
VersionTestCase, VersionTestCase,
GenerateTestCase,
NewTestCase, NewTestCase,
GenerateTestCase,
# project needed # project needed
BuildTestCase, BuildTestCase,
PublishTestCase, PublishTestCase,
@@ -75,4 +75,4 @@ class CLITestSuite(unittest.TestSuite):
def run(self, *args): def run(self, *args):
self._setup() self._setup()
self._result = super().run(*args) self._result = super().run(*args)
self._cleanup() # self._cleanup()

View File

@@ -1,41 +1,89 @@
import os.path import os.path
import unittest import unittest
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
class GenerateTestCase(unittest.TestCase): class GenerateTestCase(unittest.TestCase):
_project = 'test-console'
_t_path = 'test'
def _test_file(self, schematic: str, suffix: str): @classmethod
CLICommands.generate(schematic, 'GeneratedFile') def setUpClass(cls):
file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, f'generated_file{suffix}.py')) 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) file_exists = os.path.exists(file_path)
self.assertTrue(file_exists) 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): def test_abc(self):
self._test_file('abc', '_abc') 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): def test_class(self):
self._test_file('class', '') 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): def test_enum(self):
self._test_file('enum', '_enum') 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): def test_pipe(self):
self._test_file('pipe', '_pipe') 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): def test_service(self):
self._test_file('service', '_service') self._test_file('service', '_service')
self._test_file_with_project('service', '_service', path=self._project)
def test_settings(self): def test_settings(self):
self._test_file('settings', '_settings') self._test_file('settings', '_settings')
self._test_file_with_project('settings', '_settings', path=self._project)
def test_test_case(self): def test_test_case(self):
self._test_file('test_case', '_test_case') self._test_file('test_case', '_test_case')
self._test_file_with_project('test_case', '_test_case', path=self._project)
def test_thread(self): def test_thread(self):
self._test_file('thread', '_thread') self._test_file('thread', '_thread')
self._test_file_with_project('thread', '_thread', path=self._project)
def test_validator(self): def test_validator(self):
self._test_file('validator', '_validator') self._test_file('validator', '_validator')
self._test_file_with_project('validator', '_validator', path=self._project)

View File

@@ -12,7 +12,7 @@ class NewTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
os.chdir(os.path.abspath(PLAYGROUND_PATH)) os.chdir(os.path.abspath(PLAYGROUND_PATH))
def _test_project(self, project_type: str, name: str, *args, test_venv=False): def _test_project(self, project_type: str, name: str, *args, test_venv=False, without_ws=False):
CLICommands.new(project_type, name, *args) CLICommands.new(project_type, name, *args)
workspace_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, name)) workspace_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, name))
self.assertTrue(os.path.exists(workspace_path)) self.assertTrue(os.path.exists(workspace_path))
@@ -22,7 +22,15 @@ class NewTestCase(unittest.TestCase):
self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv/bin/python'))) self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv/bin/python')))
self.assertTrue(os.path.islink(os.path.join(workspace_path, 'venv/bin/python'))) self.assertTrue(os.path.islink(os.path.join(workspace_path, 'venv/bin/python')))
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, name, 'src', String.convert_to_snake_case(name))) base = 'src'
if '--base' in args and '/' in name:
base = name.split('/')[0]
name = name.replace(f'{name.split("/")[0]}/', '')
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, name, base, String.convert_to_snake_case(name)))
if without_ws:
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, base, name, 'src/', String.convert_to_snake_case(name)))
self.assertTrue(os.path.exists(project_path)) self.assertTrue(os.path.exists(project_path))
self.assertTrue(os.path.join(project_path, f'{name}.json')) self.assertTrue(os.path.join(project_path, f'{name}.json'))
self.assertTrue(os.path.join(project_path, f'main.py')) self.assertTrue(os.path.join(project_path, f'main.py'))
@@ -54,7 +62,12 @@ class NewTestCase(unittest.TestCase):
self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv/bin/python'))) self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv/bin/python')))
self.assertTrue(os.path.islink(os.path.join(workspace_path, 'venv/bin/python'))) self.assertTrue(os.path.islink(os.path.join(workspace_path, 'venv/bin/python')))
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, workspace_name, 'src', String.convert_to_snake_case(name))) base = 'src'
if '--base' in args and '/' in name:
base = name.split('/')[0]
name = name.replace(f'{name.split("/")[0]}/', '')
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, workspace_name, base, String.convert_to_snake_case(name)))
self.assertTrue(os.path.exists(project_path)) self.assertTrue(os.path.exists(project_path))
self.assertTrue(os.path.join(project_path, f'{name}.json')) self.assertTrue(os.path.join(project_path, f'{name}.json'))
os.chdir(os.path.abspath(os.path.join(os.getcwd(), '../'))) os.chdir(os.path.abspath(os.path.join(os.getcwd(), '../')))
@@ -88,6 +101,9 @@ class NewTestCase(unittest.TestCase):
def test_console(self): def test_console(self):
self._test_project('console', 'test-console', '--ab', '--s', '--venv', test_venv=True) self._test_project('console', 'test-console', '--ab', '--s', '--venv', test_venv=True)
def test_console_with_other_base(self):
self._test_project('console', 'tools/test-console', '--ab', '--s', '--venv', '--base', test_venv=True, without_ws=True)
def test_console_without_s(self): def test_console_without_s(self):
self._test_project('console', 'test-console-without-s', '--ab') self._test_project('console', 'test-console-without-s', '--ab')
@@ -100,6 +116,9 @@ class NewTestCase(unittest.TestCase):
def test_sub_console(self): def test_sub_console(self):
self._test_sub_project('console', 'test-sub-console', 'test-console', '--ab', '--s', '--sp', '--venv', test_venv=True) self._test_sub_project('console', 'test-sub-console', 'test-console', '--ab', '--s', '--sp', '--venv', test_venv=True)
def test_sub_console_with_other_base(self):
self._test_sub_project('console', 'tools/test-sub-console', 'test-console', '--ab', '--s', '--sp', '--venv', '--base', test_venv=True)
def test_library(self): def test_library(self):
self._test_project('library', 'test-library', '--ab', '--s', '--sp') self._test_project('library', 'test-library', '--ab', '--s', '--sp')

View File

@@ -20,9 +20,7 @@
"cpl-cli>=2022.10.0" "cpl-cli>=2022.10.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [], "Classifiers": [],
"DevDependencies": [] "DevDependencies": []
}, },

View File

@@ -22,7 +22,7 @@ class UpdateTestCase(unittest.TestCase):
self._old_package = f'{self._old_package_name}=={self._old_version}' self._old_package = f'{self._old_package_name}=={self._old_version}'
# todo: better way to do shit required # 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_name = 'discord.py'
self._new_package = f'{self._new_package_name}=={self._new_version}' self._new_package = f'{self._new_package_name}=={self._new_version}'

View File

@@ -19,9 +19,7 @@
"cpl-core>=2022.10.0" "cpl-core>=2022.10.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [], "Classifiers": [],
"DevDependencies": [] "DevDependencies": []
}, },

View File

@@ -20,9 +20,7 @@
"cpl-query>=2022.10.0" "cpl-query>=2022.10.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [], "Classifiers": [],
"DevDependencies": [] "DevDependencies": []
}, },

View File

@@ -19,9 +19,7 @@
"cpl-core>=2022.10.0" "cpl-core>=2022.10.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [], "Classifiers": [],
"DevDependencies": [] "DevDependencies": []
}, },

View File

@@ -23,9 +23,7 @@
"cpl-cli>=2022.10.0" "cpl-cli>=2022.10.0"
], ],
"PythonVersion": ">=3.10.4", "PythonVersion": ">=3.10.4",
"PythonPath": { "PythonPath": {},
"linux": ""
},
"Classifiers": [] "Classifiers": []
}, },
"BuildSettings": { "BuildSettings": {