From 9ef217339f7fca7e1557c193f71a514068bd4e1f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 13:54:19 +0000 Subject: [PATCH] test(config): cover auto-created config directory Agent-Logs-Url: https://github.com/rommapp/romm/sessions/0c94e1c8-0f79-4f5f-a72b-e45832906d00 Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com> --- backend/config/config_manager.py | 11 +++++------ backend/tests/config/test_config_loader.py | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/config/config_manager.py b/backend/config/config_manager.py index 1c17ad854..283ffbc5d 100644 --- a/backend/config/config_manager.py +++ b/backend/config/config_manager.py @@ -4,6 +4,7 @@ import glob import json import os import sys +from pathlib import Path from typing import Final, NotRequired, TypedDict import pydash @@ -189,16 +190,14 @@ class ConfigManager: self._validate_config() def _create_missing_config_file(self) -> None: - log.warning(f"Config file not found, creating an empty config at {hl(self.config_file, BLUE)}") + log.warning( + f"Config file not found, creating an empty config at {hl(self.config_file, BLUE)}" + ) try: os.makedirs(os.path.dirname(self.config_file), exist_ok=True) - with open(self.config_file, "x"): - pass + Path(self.config_file).touch(exist_ok=True) - self._config_file_mounted = True - self._config_file_writable = os.access(self.config_file, os.W_OK) - except FileExistsError: self._config_file_mounted = True self._config_file_writable = os.access(self.config_file, os.W_OK) except PermissionError: diff --git a/backend/tests/config/test_config_loader.py b/backend/tests/config/test_config_loader.py index faa9c8d10..72b57f940 100644 --- a/backend/tests/config/test_config_loader.py +++ b/backend/tests/config/test_config_loader.py @@ -120,6 +120,7 @@ def test_missing_config_file_is_created(tmp_path): loader = ConfigManager(str(config_file)) + assert config_file.parent.exists() assert config_file.exists() assert config_file.read_text() == "" assert loader.config.CONFIG_FILE_MOUNTED