diff --git a/src/superannotate/lib/app/interface/cli_interface.py b/src/superannotate/lib/app/interface/cli_interface.py index c15b5c924..8a977ed7f 100644 --- a/src/superannotate/lib/app/interface/cli_interface.py +++ b/src/superannotate/lib/app/interface/cli_interface.py @@ -51,6 +51,7 @@ def init( """ from configparser import ConfigParser + os.makedirs(constances.LOG_FILE_LOCATION, exist_ok=True) if Path(constances.CONFIG_INI_FILE_LOCATION).exists(): operation = "updated" if not input( @@ -59,10 +60,8 @@ def init( return else: operation = "created" - config_parser = ConfigParser() config_parser.optionxform = str - config_parser["DEFAULT"] = { "SA_TOKEN": token, "LOGGING_LEVEL": logging_level, diff --git a/tests/integration/test_cli.py b/tests/integration/test_cli.py index c3c5ce34c..5961af66b 100644 --- a/tests/integration/test_cli.py +++ b/tests/integration/test_cli.py @@ -209,14 +209,17 @@ def test_create_server(self): def test_init(self): _token = "asd=123" with tempfile.TemporaryDirectory() as config_dir: - config_ini_path = f"{config_dir}/config.ini" - with patch("lib.core.CONFIG_INI_FILE_LOCATION", config_ini_path): + ini_path = config_dir + "/config.ini" + log_path = config_dir + "/logs" + with patch("lib.core.LOG_FILE_LOCATION", log_path),\ + patch('lib.core.CONFIG_INI_FILE_LOCATION', ini_path): self.safe_run(self._cli.init, _token) config = ConfigParser() - config.read(config_ini_path) + config.read(ini_path) assert config["DEFAULT"]["SA_TOKEN"] == _token assert config["DEFAULT"]["LOGGING_LEVEL"] == "INFO" assert config["DEFAULT"]["LOGGING_PATH"] == f"{constants.LOG_FILE_LOCATION}" + assert os.path.exists(log_path) def test_init_with_logging_configs(self): _token = "asd=123"