mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
* refactor actions and events * remove type_key * remove stream * move import * move import * fix NullObs * reorder imports * fix lint * fix dataclasses * remove blank fields * fix nullobs * fix sidebar labels * fix test compilation * switch to asdict * lint * fix whitespace * fix executable * delint * fix run * remove NotImplementeds * fix path prefix * remove null files * add debug * add more debug info * fix dataclass on null * remove debug * revert sandbox * fix merge issues * fix tyeps * Update opendevin/events/action/browse.py
25 lines
1.3 KiB
Python
25 lines
1.3 KiB
Python
from opendevin.events.observation import (
|
|
CmdOutputObservation,
|
|
Observation,
|
|
observation_from_dict,
|
|
)
|
|
|
|
|
|
def test_observation_serialization_deserialization():
|
|
original_observation_dict = {
|
|
'observation': 'run',
|
|
'extras': {'exit_code': 0, 'command': 'ls -l', 'command_id': 3},
|
|
'message': 'Command `ls -l` executed with exit code 0.',
|
|
'content': 'foo.txt',
|
|
}
|
|
observation_instance = observation_from_dict(original_observation_dict)
|
|
assert isinstance(observation_instance, Observation), 'The observation instance should be an instance of Action.'
|
|
assert isinstance(observation_instance, CmdOutputObservation), 'The observation instance should be an instance of AgentThinkAction.'
|
|
serialized_observation_dict = observation_instance.to_dict()
|
|
serialized_observation_memory = observation_instance.to_memory()
|
|
assert serialized_observation_dict == original_observation_dict, 'The serialized observation should match the original observation dict.'
|
|
original_observation_dict.pop('message')
|
|
assert serialized_observation_memory == original_observation_dict, 'The serialized observation in memory should match the original observation dict.'
|
|
|
|
# Additional tests for various observation subclasses can be included here
|