Skip to content

Commit a4b08ea

Browse files
committed
test: update create and delete button unit tests to include wait_ready checkbox
Signed-off-by: Bobbins228 <[email protected]>
1 parent 3190224 commit a4b08ea

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tests/unit_test.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -2896,28 +2896,40 @@ def test_cluster_up_down_buttons(mocker):
28962896
)
28972897
cluster = Cluster(createClusterConfig())
28982898

2899-
with patch("ipywidgets.Button") as MockButton, patch("ipywidgets.Output"), patch(
2900-
"ipywidgets.HBox"
2901-
), patch.object(cluster, "up") as mock_up, patch.object(
2899+
with patch("ipywidgets.Button") as MockButton, patch(
2900+
"ipywidgets.Checkbox"
2901+
) as MockCheckbox, patch("ipywidgets.Output"), patch("ipywidgets.HBox"), patch(
2902+
"ipywidgets.VBox"
2903+
), patch.object(
2904+
cluster, "up"
2905+
) as mock_up, patch.object(
29022906
cluster, "down"
2903-
) as mock_down:
2904-
# Create mock button instances
2907+
) as mock_down, patch.object(
2908+
cluster, "wait_ready"
2909+
) as mock_wait_ready:
2910+
# Create mock button & CheckBox instances
29052911
mock_up_button = MagicMock()
29062912
mock_down_button = MagicMock()
2913+
mock_wait_ready_check_box = MagicMock()
29072914

29082915
# Ensure the mock Button class returns the mock button instances in sequence
2916+
MockCheckbox.side_effect = [mock_wait_ready_check_box]
29092917
MockButton.side_effect = [mock_up_button, mock_down_button]
29102918

29112919
# Call the method under test
29122920
cluster._cluster_up_down_buttons()
29132921

2922+
# Simulate checkbox being checked or unchecked
2923+
mock_wait_ready_check_box.value = True # Simulate checkbox being checked
2924+
29142925
# Simulate the button clicks by calling the mock on_click handlers
29152926
mock_up_button.on_click.call_args[0][0](None) # Simulate clicking "Cluster Up"
29162927
mock_down_button.on_click.call_args[0][0](
29172928
None
29182929
) # Simulate clicking "Cluster Down"
29192930

29202931
# Check if the `up` and `down` methods were called
2932+
mock_wait_ready.assert_called_once()
29212933
mock_up.assert_called_once()
29222934
mock_down.assert_called_once()
29232935

0 commit comments

Comments
 (0)