Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren committed Nov 26, 2024
1 parent 6179187 commit e322853
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 5 additions & 2 deletions openhands/server/file_config.py
Original file line number Diff line number Diff line change
@@ -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/',
Expand All @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions tests/unit/test_listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit e322853

Please sign in to comment.