diff --git a/openhands/server/file_config.py b/openhands/server/file_config.py index 465060c6ce0e..06e8ce20eeb4 100644 --- a/openhands/server/file_config.py +++ b/openhands/server/file_config.py @@ -1,8 +1,9 @@ import os import re +from openhands.core.config import AppConfig from openhands.core.logger import openhands_logger as logger -from openhands.server.shared import config +from openhands.server.shared import config as shared_config FILES_TO_IGNORE = [ '.git/', @@ -26,7 +27,9 @@ def sanitize_filename(filename): return filename -def load_file_upload_config() -> tuple[int, bool, list[str]]: +def load_file_upload_config( + config: AppConfig = shared_config, +) -> tuple[int, bool, list[str]]: """Load file upload configuration from the config object. This function retrieves the file upload settings from the global config object. diff --git a/tests/unit/test_listen.py b/tests/unit/test_listen.py index e6cd4b9a0ce6..f19be8aedb49 100644 --- a/tests/unit/test_listen.py +++ b/tests/unit/test_listen.py @@ -31,12 +31,11 @@ def test_load_file_upload_config(): file_uploads_restrict_file_types=True, file_uploads_allowed_extensions=['.txt', '.pdf'], ) - with patch('openhands.server.shared.config', config): - max_size, restrict_types, allowed_extensions = load_file_upload_config() + max_size, restrict_types, allowed_extensions = load_file_upload_config(config) - assert max_size == 10 - assert restrict_types is True - assert set(allowed_extensions) == {'.txt', '.pdf'} + assert max_size == 10 + assert restrict_types is True + assert set(allowed_extensions) == {'.txt', '.pdf'} def test_load_file_upload_config_invalid_max_size():