mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-08 22:38:05 -05:00
* mypy is invaluable * fix config, add test * Add new-style toml support * add singleton, small doc fixes * fix some cases of loading toml, clean up, try to make it clearer * Add defaults_dict for UI * allow config to be mutable error handling fix toml parsing * remove debug stuff * Adapt Makefile * Add defaults for temperature and top_p * update to CodeActAgent * comments * fix unit tests * implement groups of llm settings (CLI) * fix merge issue * small fix sandboxes, small refactoring * adapt LLM init to accept overrides at runtime * reading config is enough * Encapsulate minimally embeddings initialization * agent bug fix; fix tests * fix sandboxes tests * refactor globals in sandboxes to properties
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.events.action 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'
|
|
)
|