Refactor digitador bot and add runtime monitoring

This commit is contained in:
erik
2026-08-30 14:02:58 -05:00
parent 3b01456875
commit d9e2012e22
46 changed files with 1720 additions and 248 deletions
@@ -0,0 +1,37 @@
from __future__ import annotations
from types import SimpleNamespace
from bot_digitador.core.application import select_document_type
class FakeWrapper:
def __init__(self):
self.keys: list[str] = []
def type_keys(self, value: str, **_kwargs) -> None:
self.keys.append(value)
def test_select_document_type_uses_home_and_exact_c_sequence():
wrapper = FakeWrapper()
window = SimpleNamespace(wrapper_object=lambda: wrapper)
clicks: list[tuple[int, int]] = []
logs: list[str] = []
ok = select_document_type(
window,
"CC",
log=logs.append,
sleep=lambda _seconds: None,
click=lambda _window, x, y: clicks.append((x, y)),
)
assert ok is True
assert clicks == [(729, 279)]
assert wrapper.keys == ["{HOME}", "c", "c", "c", "{ENTER}"]
def test_select_document_type_rejects_unknown_type():
assert select_document_type(SimpleNamespace(), "XX", log=lambda _message: None) is False