Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/superannotate/lib/app/interface/cli_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions tests/integration/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down