forked from All-Hands-AI/OpenHands
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Event.parents property to track event provenance
- Loading branch information
1 parent
b93a15e
commit 58f8db6
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
|
||
from openhands.events.event import Event, ParentEvent | ||
|
||
|
||
def test_event_parents_property(): | ||
# Test initial state | ||
event = Event() | ||
assert event.parents is None | ||
|
||
# Test setting and getting parents | ||
parent_events = [ | ||
ParentEvent(id=1, method="process_a"), | ||
ParentEvent(id=2, method="process_b") | ||
] | ||
event.parents = parent_events | ||
|
||
# Verify parents are set correctly | ||
assert event.parents is not None | ||
assert len(event.parents) == 2 | ||
assert event.parents[0].id == 1 | ||
assert event.parents[0].method == "process_a" | ||
assert event.parents[1].id == 2 | ||
assert event.parents[1].method == "process_b" | ||
|
||
|
||
def test_parent_event_dataclass(): | ||
# Test ParentEvent creation | ||
parent = ParentEvent(id=1, method="test_method") | ||
assert parent.id == 1 | ||
assert parent.method == "test_method" | ||
|
||
# Test equality | ||
parent2 = ParentEvent(id=1, method="test_method") | ||
assert parent == parent2 | ||
|
||
# Test different values | ||
parent3 = ParentEvent(id=2, method="other_method") | ||
assert parent != parent3 |