CAM: Fix Gui test for ToolBitBrowserWidget

This commit is contained in:
Samuel Abels
2025-05-19 21:02:41 +02:00
parent e94ff039c9
commit f384656d87
2 changed files with 7 additions and 1 deletions

View File

@@ -41,6 +41,9 @@ class TestToolBitBrowserWidget(PathTestWithAssets):
self.widget = ToolBitBrowserWidget(self.assets)
def test_initial_fetch(self):
# Simulate expose to trigger initial fetch
self.widget.showEvent(None)
# Verify that the list widget is populated after initialization
# The default test assets include some toolbits.
self.assertGreater(self.widget._tool_list_widget.count(), 0)
@@ -79,6 +82,9 @@ class TestToolBitBrowserWidget(PathTestWithAssets):
if is_expected:
expected_visible_uris.add(str(tb.get_uri()))
# Simulate expose to trigger initial fetch
self.widget.showEvent(None)
actual_visible_uris = set()
for i in range(self.widget._tool_list_widget.count()):
item = self.widget._tool_list_widget.item(i)

View File

@@ -133,9 +133,9 @@ class ToolBitBrowserWidget(QtGui.QWidget):
),
)
self._sort_assets()
self._trigger_fetch()
finally:
self._is_fetching = False
self._trigger_fetch()
def _sort_assets(self):
"""Sorts the in-memory assets based on the current sort key."""