cli discord unterstützung (#143) #146
@@ -18,7 +18,6 @@ class ProjectFileAppsettings(FileTemplateABC):
 | 
				
			|||||||
            "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
 | 
					            "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
 | 
				
			||||||
            "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
 | 
					            "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
          "LoggingSettings": {
 | 
					          "LoggingSettings": {
 | 
				
			||||||
            "Path": "logs/",
 | 
					            "Path": "logs/",
 | 
				
			||||||
            "Filename": "log_$start_time.log",
 | 
					            "Filename": "log_$start_time.log",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,6 @@ class CommandTestCase(unittest.TestCase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @classmethod
 | 
					    @classmethod
 | 
				
			||||||
    def setUpClass(cls):
 | 
					    def setUpClass(cls):
 | 
				
			||||||
 | 
					 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            if os.path.exists(PLAYGROUND_PATH):
 | 
					            if os.path.exists(PLAYGROUND_PATH):
 | 
				
			||||||
                shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH)))
 | 
					                shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH)))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,6 @@ from unittests_shared.cli_commands import CLICommands
 | 
				
			|||||||
class GenerateTestCase(CommandTestCase):
 | 
					class GenerateTestCase(CommandTestCase):
 | 
				
			||||||
    _project = 'test-console'
 | 
					    _project = 'test-console'
 | 
				
			||||||
    _t_path = 'test'
 | 
					    _t_path = 'test'
 | 
				
			||||||
    _skip_tear_down = True
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @classmethod
 | 
					    @classmethod
 | 
				
			||||||
    def setUpClass(cls):
 | 
					    def setUpClass(cls):
 | 
				
			||||||
@@ -45,7 +44,6 @@ class GenerateTestCase(CommandTestCase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        CLICommands.generate(schematic, file)
 | 
					        CLICommands.generate(schematic, file)
 | 
				
			||||||
        file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, excepted_path))
 | 
					        file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, excepted_path))
 | 
				
			||||||
        print(file_path)
 | 
					 | 
				
			||||||
        self.assertTrue(os.path.exists(file_path))
 | 
					        self.assertTrue(os.path.exists(file_path))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_abc(self):
 | 
					    def test_abc(self):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,43 +2,21 @@ import filecmp
 | 
				
			|||||||
import json
 | 
					import json
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
import unittest
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cpl_core.utils import String
 | 
					from cpl_core.utils import String
 | 
				
			||||||
from unittests_cli.abc.command_test_case import CommandTestCase
 | 
					from unittests_cli.abc.command_test_case import CommandTestCase
 | 
				
			||||||
 | 
					 | 
				
			||||||
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 PublishTestCase(CommandTestCase):
 | 
					class PublishTestCase(CommandTestCase):
 | 
				
			||||||
 | 
					    _skip_tear_down = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, method_name: str):
 | 
					    def __init__(self, method_name: str):
 | 
				
			||||||
        CommandTestCase.__init__(self, method_name)
 | 
					        CommandTestCase.__init__(self, method_name)
 | 
				
			||||||
        self._source = 'publish-test-source'
 | 
					        self._source = 'publish-test-source'
 | 
				
			||||||
        self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
 | 
					        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:
 | 
					 | 
				
			||||||
            # load json
 | 
					 | 
				
			||||||
            project_json = json.load(cfg)
 | 
					 | 
				
			||||||
            cfg.close()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return project_json
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def _get_appsettings(self):
 | 
					 | 
				
			||||||
        with open(os.path.join(os.getcwd(), os.path.dirname(self._project_file), 'appsettings.json'), 'r', encoding='utf-8') as cfg:
 | 
					 | 
				
			||||||
            # load json
 | 
					 | 
				
			||||||
            project_json = json.load(cfg)
 | 
					 | 
				
			||||||
            cfg.close()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        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:
 | 
					 | 
				
			||||||
            project_file.write(json.dumps(settings, indent=2))
 | 
					 | 
				
			||||||
            project_file.close()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        if not os.path.exists(PLAYGROUND_PATH):
 | 
					        if not os.path.exists(PLAYGROUND_PATH):
 | 
				
			||||||
            os.makedirs(PLAYGROUND_PATH)
 | 
					            os.makedirs(PLAYGROUND_PATH)
 | 
				
			||||||
@@ -91,11 +69,8 @@ class PublishTestCase(CommandTestCase):
 | 
				
			|||||||
        self.assertTrue(os.path.exists(os.path.join(setup_path, f'{String.convert_to_snake_case(self._source)}-0.0.0-py3-none-any.whl')))
 | 
					        self.assertTrue(os.path.exists(os.path.join(setup_path, f'{String.convert_to_snake_case(self._source)}-0.0.0-py3-none-any.whl')))
 | 
				
			||||||
        self.assertTrue(os.path.exists(full_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))
 | 
					        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()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with open(f'{full_dist_path}/appsettings.json', 'w') as file:
 | 
					        shutil.copyfile(os.path.join(os.getcwd(), self._project_file), f'{full_dist_path}/{self._source}.json')
 | 
				
			||||||
            file.write(json.dumps(self._get_appsettings(), indent=2))
 | 
					        shutil.copyfile(os.path.join(os.getcwd(), os.path.dirname(self._project_file), 'appsettings.json'), f'{full_dist_path}/appsettings.json')
 | 
				
			||||||
            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))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user