tiny-computer-agent / tests /test_windows_platform.py
hkblockchaintechnology's picture
Publish tests/ from marimo
d0b825c verified
Raw History Blame Contribute Delete
2.23 kB
"""The things only real Windows can verify.
Skipped everywhere else, so the suite stays green on Linux while these stay honest:
they are the reason `display_available()` and the capture backend are more than an
assertion about a code path. The `windows-latest` CI job runs them, and so does a
Windows machine with `-m pytest tests/test_windows_platform.py`.
"""
import os
import platform
import pytest
WINDOWS = platform.system() == "Windows"
pytestmark = pytest.mark.skipif(not WINDOWS, reason="needs real Windows")
def test_display_available_says_so_on_windows():
from tiny_computer_agent import display_available
ok, detail = display_available()
assert ok is True
assert "Windows" in detail
def test_capture_returns_the_real_screen():
from tiny_computer_agent import GrabScreen
observation = GrabScreen(monitor=1).capture()
frame = observation.frame
assert frame.width > 100 and frame.height > 100
sampled = {pixel for row in list(frame.resize((8, 8)).getdata()) for pixel in [row]}
assert len(sampled) > 1, "the screenshot came back as one flat colour"
def test_a_detector_that_needs_nothing_still_indexes_the_screen():
from tiny_computer_agent import GrabScreen, make_detector
frame = GrabScreen(monitor=1).capture().frame
assert len(make_detector("grid").detect(frame)) == 96
def test_ui_automation_is_reported_truthfully():
from tiny_computer_agent import accessibility_available
ok, detail = accessibility_available("uia")
assert isinstance(ok, bool) and detail
def test_the_doctor_reports_a_ready_windows_desktop():
from tiny_computer_agent import run_checks
checks = {check.name: check for check in run_checks(brain="planner", detector="grid")}
assert checks["display server"].ok is True
assert checks["pillow"].ok is True
@pytest.mark.skipif(os.environ.get("TINY_COMPUTER_AGENT_LIVE_TEST") != "1",
reason="moves the real mouse: opt in, and use a throwaway desktop")
def test_the_real_mouse_goes_where_it_is_asked():
pyautogui = pytest.importorskip("pyautogui")
pyautogui.moveTo(120, 140)
assert abs(pyautogui.position().x - 120) <= 2
assert abs(pyautogui.position().y - 140) <= 2