Skip to content

Commit 18f42d8

Browse files
authored
Merge pull request #564 from superannotateai/cli_init_fix
Cli init fix
2 parents 9abe91c + 07e000e commit 18f42d8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/superannotate/lib/app/interface/cli_interface.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def init(
5151
"""
5252
from configparser import ConfigParser
5353

54+
os.makedirs(constances.LOG_FILE_LOCATION, exist_ok=True)
5455
if Path(constances.CONFIG_INI_FILE_LOCATION).exists():
5556
operation = "updated"
5657
if not input(
@@ -59,10 +60,8 @@ def init(
5960
return
6061
else:
6162
operation = "created"
62-
6363
config_parser = ConfigParser()
6464
config_parser.optionxform = str
65-
6665
config_parser["DEFAULT"] = {
6766
"SA_TOKEN": token,
6867
"LOGGING_LEVEL": logging_level,

tests/integration/test_cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,17 @@ def test_create_server(self):
209209
def test_init(self):
210210
_token = "asd=123"
211211
with tempfile.TemporaryDirectory() as config_dir:
212-
config_ini_path = f"{config_dir}/config.ini"
213-
with patch("lib.core.CONFIG_INI_FILE_LOCATION", config_ini_path):
212+
ini_path = config_dir + "/config.ini"
213+
log_path = config_dir + "/logs"
214+
with patch("lib.core.LOG_FILE_LOCATION", log_path),\
215+
patch('lib.core.CONFIG_INI_FILE_LOCATION', ini_path):
214216
self.safe_run(self._cli.init, _token)
215217
config = ConfigParser()
216-
config.read(config_ini_path)
218+
config.read(ini_path)
217219
assert config["DEFAULT"]["SA_TOKEN"] == _token
218220
assert config["DEFAULT"]["LOGGING_LEVEL"] == "INFO"
219221
assert config["DEFAULT"]["LOGGING_PATH"] == f"{constants.LOG_FILE_LOCATION}"
222+
assert os.path.exists(log_path)
220223

221224
def test_init_with_logging_configs(self):
222225
_token = "asd=123"

0 commit comments

Comments
 (0)