mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* Feat: add stream output to exec_run * Using command timeout to control the exec_box's timeout. * add bash -c to source command to compatible for sh. Signed-off-by: ifuryst <ifuryst@gmail.com> * Feat: add stream output to SSHBox execute Signed-off-by: ifuryst <ifuryst@gmail.com> * fix the test case fail. Signed-off-by: ifuryst <ifuryst@gmail.com> * fix the test case import wrong path for method. Signed-off-by: ifuryst <ifuryst@gmail.com> --------- Signed-off-by: ifuryst <ifuryst@gmail.com>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from opendevin.core.config import config
|
|
from opendevin.runtime.server import files
|
|
|
|
SANDBOX_PATH_PREFIX = '/workspace'
|
|
|
|
|
|
def test_resolve_path():
|
|
assert (
|
|
files.resolve_path('test.txt', '/workspace')
|
|
== Path(config.workspace_base) / 'test.txt'
|
|
)
|
|
assert (
|
|
files.resolve_path('subdir/test.txt', '/workspace')
|
|
== Path(config.workspace_base) / 'subdir' / 'test.txt'
|
|
)
|
|
assert (
|
|
files.resolve_path(Path(SANDBOX_PATH_PREFIX) / 'test.txt', '/workspace')
|
|
== Path(config.workspace_base) / 'test.txt'
|
|
)
|
|
assert (
|
|
files.resolve_path(
|
|
Path(SANDBOX_PATH_PREFIX) / 'subdir' / 'test.txt', '/workspace'
|
|
)
|
|
== Path(config.workspace_base) / 'subdir' / 'test.txt'
|
|
)
|
|
assert (
|
|
files.resolve_path(
|
|
Path(SANDBOX_PATH_PREFIX) / 'subdir' / '..' / 'test.txt', '/workspace'
|
|
)
|
|
== Path(config.workspace_base) / 'test.txt'
|
|
)
|
|
with pytest.raises(PermissionError):
|
|
files.resolve_path(Path(SANDBOX_PATH_PREFIX) / '..' / 'test.txt', '/workspace')
|
|
with pytest.raises(PermissionError):
|
|
files.resolve_path(Path('..') / 'test.txt', '/workspace')
|
|
with pytest.raises(PermissionError):
|
|
files.resolve_path(Path('/') / 'test.txt', '/workspace')
|
|
assert (
|
|
files.resolve_path('test.txt', '/workspace/test')
|
|
== Path(config.workspace_base) / 'test' / 'test.txt'
|
|
)
|