fix: test fix to change clicks to box drawing

This commit is contained in:
Zoe
2026-09-21 00:04:35 -05:00
parent d4b5ea0254
commit 4b08ce05a4
5 changed files with 37 additions and 8 deletions
+9 -1
View File
@@ -17,7 +17,7 @@ spec.loader.exec_module(desktop)
class ValidationTests(unittest.TestCase):
def test_settling_delay_precedes_final_capture_only_after_actions(self):
for actions in ([], [{"type": "click", "x": 500, "y": 500}]):
for actions in ([], [{"type": "click", "ymin": 400, "xmin": 400, "ymax": 600, "xmax": 600}]):
events = []
image = Mock(size=(1280, 800), width=1280, height=800)
def grab(**kwargs):
@@ -66,11 +66,17 @@ class ValidationTests(unittest.TestCase):
def test_normalized_coordinates(self):
for value, expected in [(0, (0, 0)), (500, (640, 400)), (1000, (1279, 799))]:
self.assertEqual(desktop.click_pixels({"x": value, "y": value}, 1280, 800, "normalized_1000"), expected)
self.assertEqual(desktop.click_pixels({"ymin": value, "xmin": value, "ymax": value, "xmax": value}, 1280, 800, "normalized_1000"), expected)
self.assertEqual(desktop.click_pixels({"ymin": 300, "xmin": 400, "ymax": 500, "xmax": 600}, 1280, 800, "normalized_1000"), (640, 320))
self.assertEqual(desktop.click_pixels({"x": 1000, "y": 1000}, 1, 1, "normalized_1000"), (0, 0))
self.assertEqual(desktop.click_pixels({"ymin": 0, "xmin": 0, "ymax": 1000, "xmax": 1000}, 1, 1, "normalized_1000"), (0, 0))
self.assertEqual(desktop.click_pixels({"x": 480, "y": 425}, 1280, 800, "pixels"), (480, 425))
self.assertEqual(desktop.click_pixels({"ymin": 400, "xmin": 460, "ymax": 450, "xmax": 500}, 1280, 800, "pixels"), (480, 425))
for value in (-1, 1001, 0.5, True):
with self.assertRaises(ValueError):
desktop.click_pixels({"x": value, "y": 0}, 1280, 800, "normalized_1000")
with self.assertRaises(ValueError):
desktop.click_pixels({"ymin": value, "xmin": 0, "ymax": 0, "xmax": 0}, 1280, 800, "normalized_1000")
def test_invalid_coordinate_space(self):
with self.assertRaises(ValueError):
@@ -83,6 +89,8 @@ class ValidationTests(unittest.TestCase):
for x in (-1, 100, True, "2"):
with self.assertRaises(ValueError):
desktop.validate({"actions": [{"type": "click", "x": x, "y": 0}]}, 100, 100)
with self.assertRaises(ValueError):
desktop.validate({"actions": [{"type": "click", "ymin": 0, "xmin": x, "ymax": 0, "xmax": 0}]}, 100, 100)
def test_invalid_keys(self):
with self.assertRaises(ValueError):