mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 13:52:43 +08:00
* refactor session mgmt * defer file handling to runtime * add todo * refactor sessions a bit more * remove messages logic from FE * fix up socket handshake * refactor frontend auth a bit * first pass at redoing file explorer * implement directory suffix * fix up file tree * close agent on websocket close * remove session saving * move file refresh * remove getWorkspace * plumb path/code differently * fix build issues * fix the tests * fix npm build * add session rehydration * fix event serialization * logspam * fix user message rehydration * add get_event fn * agent state restoration * change history tracking for codeact * fix responsiveness of init * fix lint * lint * delint * fix prop * update tests * logspam * lint * fix test * revert codeact * change fileService to use API * fix up session loading * delint * delint * fix integration tests * revert test * fix up access to options endpoints * fix initial files load * delint * fix file initialization * fix mock server * fixl int * fix auth for html * Update frontend/src/i18n/translation.json Co-authored-by: Xingyao Wang <xingyao6@illinois.edu> * refactor sessions and sockets * avoid reinitializing the same session * fix reconnect issue * change up intro message * more guards on reinit * rename agent_session * delint * fix a bunch of tests * delint * fix last test * remove code editor context * fix build * fix any * fix dot notation * Update frontend/src/services/api.ts Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk> * fix up error handling * Update opendevin/server/session/agent.py Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk> * Update opendevin/server/session/agent.py Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk> * Update frontend/src/services/session.ts Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk> * fix build errs * fix else * add closed state * delint * Update opendevin/server/session/session.py Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> --------- Co-authored-by: Xingyao Wang <xingyao6@illinois.edu> Co-authored-by: Graham Neubig <neubig@gmail.com> Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
import os
|
|
import shutil
|
|
|
|
import pytest
|
|
|
|
from opendevin.storage.local import LocalFileStore
|
|
from opendevin.storage.memory import InMemoryFileStore
|
|
|
|
|
|
@pytest.fixture
|
|
def setup_env():
|
|
os.makedirs('./_test_files_tmp', exist_ok=True)
|
|
|
|
yield
|
|
|
|
shutil.rmtree('./_test_files_tmp')
|
|
|
|
|
|
def test_basic_fileops(setup_env):
|
|
filename = 'test.txt'
|
|
for store in [LocalFileStore('./_test_files_tmp'), InMemoryFileStore()]:
|
|
store.write(filename, 'Hello, world!')
|
|
assert store.read(filename) == 'Hello, world!'
|
|
assert store.list('') == [filename]
|
|
store.delete(filename)
|
|
with pytest.raises(FileNotFoundError):
|
|
store.read(filename)
|
|
|
|
|
|
def test_complex_path_fileops(setup_env):
|
|
filenames = ['foo.bar.baz', './foo/bar/baz', 'foo/bar/baz', '/foo/bar/baz']
|
|
for store in [LocalFileStore('./_test_files_tmp'), InMemoryFileStore()]:
|
|
for filename in filenames:
|
|
store.write(filename, 'Hello, world!')
|
|
assert store.read(filename) == 'Hello, world!'
|
|
store.delete(filename)
|
|
with pytest.raises(FileNotFoundError):
|
|
store.read(filename)
|
|
|
|
|
|
def test_list(setup_env):
|
|
for store in [LocalFileStore('./_test_files_tmp'), InMemoryFileStore()]:
|
|
store.write('foo.txt', 'Hello, world!')
|
|
store.write('bar.txt', 'Hello, world!')
|
|
store.write('baz.txt', 'Hello, world!')
|
|
assert store.list('').sort() == ['foo.txt', 'bar.txt', 'baz.txt'].sort()
|
|
store.delete('foo.txt')
|
|
store.delete('bar.txt')
|
|
store.delete('baz.txt')
|
|
|
|
|
|
def test_deep_list(setup_env):
|
|
for store in [LocalFileStore('./_test_files_tmp'), InMemoryFileStore()]:
|
|
store.write('foo/bar/baz.txt', 'Hello, world!')
|
|
store.write('foo/bar/qux.txt', 'Hello, world!')
|
|
store.write('foo/bar/quux.txt', 'Hello, world!')
|
|
assert store.list('') == ['foo/'], f'for class {store.__class__}'
|
|
assert store.list('foo') == ['foo/bar/']
|
|
assert (
|
|
store.list('foo/bar').sort()
|
|
== ['foo/bar/baz.txt', 'foo/bar/qux.txt', 'foo/bar/quux.txt'].sort()
|
|
)
|
|
store.delete('foo/bar/baz.txt')
|
|
store.delete('foo/bar/qux.txt')
|
|
store.delete('foo/bar/quux.txt')
|