mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
Add event synchronously (#2700)
* add to event stream sync * remove async from tests
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from opendevin.events import EventSource, EventStream
|
||||
from opendevin.events.action import NullAction
|
||||
from opendevin.events.observation import NullObservation
|
||||
@@ -11,17 +9,15 @@ def collect_events(stream):
|
||||
return [event for event in stream.get_events()]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_basic_flow():
|
||||
def test_basic_flow():
|
||||
stream = EventStream('abc')
|
||||
await stream.add_event(NullAction(), EventSource.AGENT)
|
||||
stream.add_event(NullAction(), EventSource.AGENT)
|
||||
assert len(collect_events(stream)) == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_stream_storage():
|
||||
def test_stream_storage():
|
||||
stream = EventStream('def')
|
||||
await stream.add_event(NullObservation(''), EventSource.AGENT)
|
||||
stream.add_event(NullObservation(''), EventSource.AGENT)
|
||||
assert len(collect_events(stream)) == 1
|
||||
content = stream._file_store.read('sessions/def/events/0.json')
|
||||
assert content is not None
|
||||
@@ -38,11 +34,10 @@ async def test_stream_storage():
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rehydration():
|
||||
def test_rehydration():
|
||||
stream1 = EventStream('es1')
|
||||
await stream1.add_event(NullObservation('obs1'), EventSource.AGENT)
|
||||
await stream1.add_event(NullObservation('obs2'), EventSource.AGENT)
|
||||
stream1.add_event(NullObservation('obs1'), EventSource.AGENT)
|
||||
stream1.add_event(NullObservation('obs2'), EventSource.AGENT)
|
||||
assert len(collect_events(stream1)) == 2
|
||||
|
||||
stream2 = EventStream('es2')
|
||||
|
||||
Reference in New Issue
Block a user