Skip to content

Commit

Permalink
Working GTK Main Window
Browse files Browse the repository at this point in the history
  • Loading branch information
ashdriod committed Nov 27, 2023
1 parent 2b30513 commit 027ade7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/test_main_window_actions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()

0 comments on commit 027ade7

Please sign in to comment.