|
11 | 11 | """ |
12 | 12 |
|
13 | 13 | from typing import Any |
14 | | -from unittest.mock import MagicMock, patch |
| 14 | +from unittest.mock import ANY, MagicMock, patch |
15 | 15 |
|
16 | 16 | import pytest |
17 | 17 |
|
@@ -245,7 +245,7 @@ def side_effect(*args, **kwargs) -> None: # noqa: ARG001 # pylint: disable=unus |
245 | 245 | @patch("tkinter.Label") |
246 | 246 | @patch("tkinter.Frame") |
247 | 247 | @patch("tkinter.Button") |
248 | | - def test_dialog_creation( |
| 248 | + def test_dialog_creation( # pylint: disable=too-many-locals |
249 | 249 | self, |
250 | 250 | mock_button: MagicMock, |
251 | 251 | mock_frame: MagicMock, |
@@ -281,5 +281,42 @@ def fake_wait_window(*args: Any, **kwargs: Any) -> None: # noqa: ANN401 # pylin |
281 | 281 | mock_toplevel.assert_called_once() |
282 | 282 |
|
283 | 283 | # Check for label, buttons, and frame creation |
284 | | - mock_label.assert_called_once() |
| 284 | + assert mock_label.call_count == 2 # message label and link label |
| 285 | + assert mock_button.call_count == 3 # Close, Yes, No buttons |
285 | 286 | mock_frame.assert_called_once() |
| 287 | + |
| 288 | + # Verify message label creation |
| 289 | + message_label_call = mock_label.call_args_list[0] |
| 290 | + assert message_label_call[1]["text"].startswith("This configuration step requires external changes by: External Tool") |
| 291 | + assert message_label_call[1]["justify"] == "left" |
| 292 | + assert message_label_call[1]["padx"] == 20 |
| 293 | + assert message_label_call[1]["pady"] == 10 |
| 294 | + |
| 295 | + # Verify link label creation |
| 296 | + link_label_call = mock_label.call_args_list[1] |
| 297 | + assert link_label_call[1]["text"] == "Click here to open the Tuning Guide relevant Section" |
| 298 | + assert link_label_call[1]["fg"] == "blue" |
| 299 | + assert link_label_call[1]["cursor"] == "hand2" |
| 300 | + # Font should be a tuple with underline |
| 301 | + font_arg = link_label_call[1]["font"] |
| 302 | + assert isinstance(font_arg, tuple) |
| 303 | + assert len(font_arg) == 3 |
| 304 | + assert font_arg[2] == "underline" |
| 305 | + |
| 306 | + # Verify link label is packed and bound correctly |
| 307 | + link_label_mock = mock_label.return_value |
| 308 | + # Both labels call pack, so check that the link label's pack call was made |
| 309 | + assert link_label_mock.pack.call_count == 2 |
| 310 | + link_label_mock.pack.assert_any_call(pady=(0, 10)) # link label pack call |
| 311 | + link_label_mock.pack.assert_any_call(padx=10, pady=10) # message label pack call |
| 312 | + link_label_mock.bind.assert_called_once_with("<Button-1>", ANY) # lambda function, so use ANY |
| 313 | + |
| 314 | + # Verify buttons are created with correct text |
| 315 | + button_calls = mock_button.call_args_list |
| 316 | + assert button_calls[0][1]["text"] == "Close" |
| 317 | + assert button_calls[1][1]["text"] == "Yes" |
| 318 | + assert button_calls[2][1]["text"] == "No" |
| 319 | + |
| 320 | + # Verify button frame is packed correctly |
| 321 | + frame_mock = mock_frame.return_value |
| 322 | + frame_mock.pack.assert_called_once_with(pady=10) |
0 commit comments