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 00100a8 commit 6179187
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/unit/test_listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_load_file_upload_config():
file_uploads_restrict_file_types=True,
file_uploads_allowed_extensions=['.txt', '.pdf'],
)
with patch('openhands.server.listen.config', config):
with patch('openhands.server.shared.config', config):
max_size, restrict_types, allowed_extensions = load_file_upload_config()

assert max_size == 10
Expand All @@ -45,7 +45,7 @@ def test_load_file_upload_config_invalid_max_size():
file_uploads_restrict_file_types=False,
file_uploads_allowed_extensions=[],
)
with patch('openhands.server.listen.config', config):
with patch('openhands.server.shared.config', config):
max_size, restrict_types, allowed_extensions = load_file_upload_config()

assert max_size == 0 # Should default to 0 when invalid
Expand All @@ -54,8 +54,8 @@ def test_load_file_upload_config_invalid_max_size():


def test_is_extension_allowed():
with patch('openhands.server.listen.RESTRICT_FILE_TYPES', True), patch(
'openhands.server.listen.ALLOWED_EXTENSIONS', ['.txt', '.pdf']
with patch('openhands.server.file_config.RESTRICT_FILE_TYPES', True), patch(
'openhands.server.file_config.ALLOWED_EXTENSIONS', ['.txt', '.pdf']
):
assert is_extension_allowed('file.txt')
assert is_extension_allowed('file.pdf')
Expand All @@ -64,16 +64,16 @@ def test_is_extension_allowed():


def test_is_extension_allowed_no_restrictions():
with patch('openhands.server.listen.RESTRICT_FILE_TYPES', False):
with patch('openhands.server.file_config.RESTRICT_FILE_TYPES', False):
assert is_extension_allowed('file.txt')
assert is_extension_allowed('file.pdf')
assert is_extension_allowed('file.doc')
assert is_extension_allowed('file')


def test_is_extension_allowed_wildcard():
with patch('openhands.server.listen.RESTRICT_FILE_TYPES', True), patch(
'openhands.server.listen.ALLOWED_EXTENSIONS', ['.*']
with patch('openhands.server.file_config.RESTRICT_FILE_TYPES', True), patch(
'openhands.server.file_config.ALLOWED_EXTENSIONS', ['.*']
):
assert is_extension_allowed('file.txt')
assert is_extension_allowed('file.pdf')
Expand Down

0 comments on commit 6179187

Please sign in to comment.