mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
Remove global config from tests (#3052)
This commit is contained in:
@@ -2,36 +2,36 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from opendevin.core.config import config
|
||||
from opendevin.runtime.server import files
|
||||
|
||||
SANDBOX_PATH_PREFIX = '/workspace'
|
||||
WORKSPACE_BASE = 'workspace'
|
||||
|
||||
|
||||
def test_resolve_path():
|
||||
assert (
|
||||
files.resolve_path('test.txt', '/workspace')
|
||||
== Path(config.workspace_base) / 'test.txt'
|
||||
== Path(WORKSPACE_BASE) / 'test.txt'
|
||||
)
|
||||
assert (
|
||||
files.resolve_path('subdir/test.txt', '/workspace')
|
||||
== Path(config.workspace_base) / 'subdir' / 'test.txt'
|
||||
== Path(WORKSPACE_BASE) / 'subdir' / 'test.txt'
|
||||
)
|
||||
assert (
|
||||
files.resolve_path(Path(SANDBOX_PATH_PREFIX) / 'test.txt', '/workspace')
|
||||
== Path(config.workspace_base) / 'test.txt'
|
||||
== Path(WORKSPACE_BASE) / 'test.txt'
|
||||
)
|
||||
assert (
|
||||
files.resolve_path(
|
||||
Path(SANDBOX_PATH_PREFIX) / 'subdir' / 'test.txt', '/workspace'
|
||||
)
|
||||
== Path(config.workspace_base) / 'subdir' / 'test.txt'
|
||||
== Path(WORKSPACE_BASE) / 'subdir' / 'test.txt'
|
||||
)
|
||||
assert (
|
||||
files.resolve_path(
|
||||
Path(SANDBOX_PATH_PREFIX) / 'subdir' / '..' / 'test.txt', '/workspace'
|
||||
)
|
||||
== Path(config.workspace_base) / 'test.txt'
|
||||
== Path(WORKSPACE_BASE) / 'test.txt'
|
||||
)
|
||||
with pytest.raises(PermissionError):
|
||||
files.resolve_path(Path(SANDBOX_PATH_PREFIX) / '..' / 'test.txt', '/workspace')
|
||||
@@ -41,5 +41,5 @@ def test_resolve_path():
|
||||
files.resolve_path(Path('/') / 'test.txt', '/workspace')
|
||||
assert (
|
||||
files.resolve_path('test.txt', '/workspace/test')
|
||||
== Path(config.workspace_base) / 'test' / 'test.txt'
|
||||
== Path(WORKSPACE_BASE) / 'test' / 'test.txt'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user