Some clean up and added interactable images.
Python CI / test (push) Successful in 6m34s

This commit is contained in:
2025-11-07 22:56:35 +01:00
parent 15305011dc
commit 49d4e551f8
7 changed files with 391 additions and 58 deletions
+18 -9
View File
@@ -442,28 +442,37 @@ class TestInteractionCallbacks(unittest.TestCase):
self.font = Font(font_size=12, colour=(0, 0, 0))
self.mock_draw = Mock()
self.callback_result = "callback_executed"
self.callback = Mock(return_value=self.callback_result)
# Link callback: receives (location, point, **params)
def link_callback(location, point, **params):
return "callback_executed"
self.link_callback = link_callback
# Button callback: receives (point, **params)
def button_callback(point, **params):
return "callback_executed"
self.button_callback = button_callback
def test_link_text_interaction(self):
"""Test that LinkText properly handles interaction"""
# Use a FUNCTION link type which calls the callback, not INTERNAL which returns location
link = Link("test_function", LinkType.FUNCTION, self.callback)
link = Link("test_function", LinkType.FUNCTION, self.link_callback)
renderable = LinkText(link, "Test Link", self.font, self.mock_draw)
# Simulate interaction
result = renderable.interact(np.array([10, 10]))
# Should execute the link's callback
self.assertEqual(result, self.callback_result)
def test_button_text_interaction(self):
"""Test that ButtonText properly handles interaction"""
button = Button("Test Button", self.callback)
button = Button("Test Button", self.button_callback)
renderable = ButtonText(button, self.font, self.mock_draw)
# Simulate interaction
result = renderable.interact(np.array([10, 10]))
# Should execute the button's callback
self.assertEqual(result, self.callback_result)