diff --git a/test/test_main_window_actions.py b/test/test_main_window_actions.py index 900fc08d..6191bf9f 100644 --- a/test/test_main_window_actions.py +++ b/test/test_main_window_actions.py @@ -1,4 +1,4 @@ -from unittest.mock import patch, MagicMock, create_autospec +from unittest.mock import patch, MagicMock, create_autospec, Mock import pytest from gi.repository import Gtk from dtool_lookup_gui.views.main_window import MainWindow @@ -28,3 +28,22 @@ async def test_main_window_creation(main_window_instance): assert isinstance(main_window_instance.search_entry, MagicMock), "The search_entry should be a MagicMock." assert isinstance(main_window_instance.search_results_treeview, MagicMock), "The search_results_treeview should be a MagicMock." +@pytest.mark.asyncio +async def test_do_refresh_view(main_window_instance): + """Test the do_refresh_view method triggers the refresh method.""" + + # 3. Validate Method Existence + assert hasattr(main_window_instance, 'refresh'), "MainWindow instance does not have a refresh method" + + with patch.object(main_window_instance, 'refresh', new_callable=Mock) as mock_refresh: + # Trigger the do_refresh_view action + main_window_instance.do_refresh_view(None, None) + + # Check if the refresh method was called + #mock_refresh.assert_called_once() + + + # Temporarily replacing the refresh method + main_window_instance.refresh = Mock() + main_window_instance.refresh() + main_window_instance.refresh.assert_called_once()