@@ -2896,28 +2896,40 @@ def test_cluster_up_down_buttons(mocker):
2896
2896
)
2897
2897
cluster = Cluster (createClusterConfig ())
2898
2898
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 (
2902
2906
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
2905
2911
mock_up_button = MagicMock ()
2906
2912
mock_down_button = MagicMock ()
2913
+ mock_wait_ready_check_box = MagicMock ()
2907
2914
2908
2915
# Ensure the mock Button class returns the mock button instances in sequence
2916
+ MockCheckbox .side_effect = [mock_wait_ready_check_box ]
2909
2917
MockButton .side_effect = [mock_up_button , mock_down_button ]
2910
2918
2911
2919
# Call the method under test
2912
2920
cluster ._cluster_up_down_buttons ()
2913
2921
2922
+ # Simulate checkbox being checked or unchecked
2923
+ mock_wait_ready_check_box .value = True # Simulate checkbox being checked
2924
+
2914
2925
# Simulate the button clicks by calling the mock on_click handlers
2915
2926
mock_up_button .on_click .call_args [0 ][0 ](None ) # Simulate clicking "Cluster Up"
2916
2927
mock_down_button .on_click .call_args [0 ][0 ](
2917
2928
None
2918
2929
) # Simulate clicking "Cluster Down"
2919
2930
2920
2931
# Check if the `up` and `down` methods were called
2932
+ mock_wait_ready .assert_called_once ()
2921
2933
mock_up .assert_called_once ()
2922
2934
mock_down .assert_called_once ()
2923
2935
0 commit comments