mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* switch default to eventstream runtime * remove pull docker from makefile * fix unittest * fix file store path * try deprecate server runtime * remove persist sandbox * move file utils * remove server runtime related workflow * remove unused method * attempt to remove the reliance on filestore for BE * fix async for list file * fix list_files to post * fix list files * add suffix to directory * make sure list file returns abs path; make sure other backend endpoints accpets abs path * remove server runtime test workflow * set git config in runtime
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from opendevin.runtime.utils import files
|
|
|
|
SANDBOX_PATH_PREFIX = '/workspace'
|
|
WORKSPACE_BASE = 'workspace'
|
|
|
|
|
|
def test_resolve_path():
|
|
assert (
|
|
files.resolve_path('test.txt', '/workspace')
|
|
== Path(WORKSPACE_BASE) / 'test.txt'
|
|
)
|
|
assert (
|
|
files.resolve_path('subdir/test.txt', '/workspace')
|
|
== Path(WORKSPACE_BASE) / 'subdir' / 'test.txt'
|
|
)
|
|
assert (
|
|
files.resolve_path(Path(SANDBOX_PATH_PREFIX) / 'test.txt', '/workspace')
|
|
== Path(WORKSPACE_BASE) / 'test.txt'
|
|
)
|
|
assert (
|
|
files.resolve_path(
|
|
Path(SANDBOX_PATH_PREFIX) / 'subdir' / 'test.txt', '/workspace'
|
|
)
|
|
== Path(WORKSPACE_BASE) / 'subdir' / 'test.txt'
|
|
)
|
|
assert (
|
|
files.resolve_path(
|
|
Path(SANDBOX_PATH_PREFIX) / 'subdir' / '..' / 'test.txt', '/workspace'
|
|
)
|
|
== Path(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(WORKSPACE_BASE) / 'test' / 'test.txt'
|
|
)
|