@@ -249,6 +249,22 @@ def test_set_sink(self, mock_check_output):
249249 ["wpctl" , "set-default" , "123" ]
250250 )
251251
252+ @patch (
253+ "checkbox_support.helpers.audio_server_utils.subprocess.check_output"
254+ )
255+ def test_set_sink_error (self , mock_check_output ):
256+ """Test setting a sink raises RuntimeError on failure."""
257+ mock_check_output .side_effect = subprocess .CalledProcessError (
258+ 1 , "wpctl"
259+ )
260+ node = Node ("dev1" , "prof1" , "sink1" , "123" , "Sink 1" )
261+
262+ with self .assertRaises (RuntimeError ) as cm :
263+ self .pipewire .set_sink (node )
264+
265+ self .assertIn ("sink1" , str (cm .exception ))
266+ self .assertIn ("123" , str (cm .exception ))
267+
252268 @patch (
253269 "checkbox_support.helpers.audio_server_utils.subprocess.check_output"
254270 )
@@ -262,6 +278,22 @@ def test_set_source(self, mock_check_output):
262278 ["wpctl" , "set-default" , "456" ]
263279 )
264280
281+ @patch (
282+ "checkbox_support.helpers.audio_server_utils.subprocess.check_output"
283+ )
284+ def test_set_source_error (self , mock_check_output ):
285+ """Test setting a source raises RuntimeError on failure."""
286+ mock_check_output .side_effect = subprocess .CalledProcessError (
287+ 1 , "wpctl"
288+ )
289+ node = Node ("dev1" , "prof1" , "source1" , "456" , "Source 1" )
290+
291+ with self .assertRaises (RuntimeError ) as cm :
292+ self .pipewire .set_source (node )
293+
294+ self .assertIn ("source1" , str (cm .exception ))
295+ self .assertIn ("456" , str (cm .exception ))
296+
265297 @patch (
266298 "checkbox_support.helpers.audio_server_utils.subprocess.check_output"
267299 )
@@ -473,6 +505,19 @@ def test_set_source(self, mock_check_output):
473505 ["pactl" , "set-default-source" , "test_source" ]
474506 )
475507
508+ @patch (
509+ "checkbox_support.helpers.audio_server_utils.subprocess.check_output"
510+ )
511+ def test_set_source_error (self , mock_check_output ):
512+ """Test setting a source raises RuntimeError on error."""
513+ mock_check_output .side_effect = subprocess .CalledProcessError (
514+ 1 , "pactl"
515+ )
516+ node = Node ("0" , None , "test_source" , "0" , "Test Source" )
517+
518+ with self .assertRaises (RuntimeError ):
519+ self .pulseaudio .set_source (node )
520+
476521 @patch (
477522 "checkbox_support.helpers.audio_server_utils.subprocess.check_output"
478523 )
0 commit comments