Skip to content

Commit

Permalink
remove test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abrichr committed May 26, 2023
1 parent 6677df3 commit e8eab59
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion puterbot/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def merge_consecutive_mouse_move_events(events, by_diff_distance=False):


def is_target_event(event, state):
return event.name == "move"
return event.name in ("click", "move")


def get_merged_events(
Expand Down
50 changes: 42 additions & 8 deletions tests/puterbot/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
DEFAULT_DT = get_double_click_interval_seconds() / 2
# set to 10 to improve output readability
OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS = None
NUM_TIMESTAMP_DIGITS = 6


rows2dicts = partial(rows2dicts, num_digits=NUM_TIMESTAMP_DIGITS)
_start_time = 0
timestamp = _start_time
timestamp_raw = _start_time
Expand Down Expand Up @@ -62,7 +64,7 @@ def make_action_event(
if "timestamp" not in event_dict:
global timestamp
global timestamp_raw
event_dict["timestamp"] = timestamp
event_dict["timestamp"] = float(timestamp)
prev_timestamp = timestamp
prev_timestamp_raw = timestamp_raw
timestamp += dt
Expand Down Expand Up @@ -321,16 +323,48 @@ def test_merge_consecutive_mouse_scroll_events():


def test_remove_redundant_mouse_move_events():
# certain failure modes only appear in longer event chains
raw_events = [
make_move_event(1),
make_move_event(2),
make_move_event(3),
make_move_event(4),
]
raw_events = list(itertools.chain(*[
[
make_move_event(1),
make_click_event(True, 1),
make_move_event(1),
make_click_event(False, 1),
make_move_event(2),
make_click_event(True, 2),
make_move_event(3),
make_click_event(False, 3),
make_move_event(3),
]
for _ in range(2)
]))
logger.info(f"raw_events=\n{pformat(rows2dicts(raw_events))}")
reset_timestamp()
expected_events = rows2dicts([
make_click_event(True, 1, get_pre_children=lambda: [
make_move_event(1),
]),
make_click_event(False, 1, get_post_children=lambda: [
make_move_event(1),
]),
make_click_event(True, 2, get_post_children=lambda: [
make_move_event(2),
]),
make_click_event(False, 3, get_post_children=lambda: [
make_move_event(3),
]),
make_click_event(True, 1, get_post_children=lambda: [
make_move_event(3),
make_move_event(1),
]),
make_click_event(False, 1, get_post_children=lambda: [
make_move_event(1),
]),
make_click_event(True, 2, get_post_children=lambda: [
make_move_event(2),
]),
make_click_event(False, 3, get_post_children=lambda: [
make_move_event(3),
]),
make_move_event(4),
])
logger.info(f"expected_events=\n{pformat(expected_events)}")
Expand Down

0 comments on commit e8eab59

Please sign in to comment.