hbmartin commited on
Commit
c664757
·
1 Parent(s): 6400f70

test_download_audio_none

Browse files
Files changed (1) hide show
  1. tests/test_cli.py +13 -0
tests/test_cli.py CHANGED
@@ -405,6 +405,19 @@ def test_download_audio(youtube, download):
405
  download.assert_called_with(audio_stream, target="target")
406
 
407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  @mock.patch("pytube.cli.YouTube.__init__", return_value=None)
409
  def test_perform_args_on_youtube(youtube):
410
  parser = argparse.ArgumentParser()
 
405
  download.assert_called_with(audio_stream, target="target")
406
 
407
 
408
+ @mock.patch("pytube.cli._download")
409
+ @mock.patch("pytube.cli.YouTube")
410
+ def test_download_audio_none(youtube, download):
411
+ # Given
412
+ youtube_instance = youtube.return_value
413
+ youtube_instance.streams.filter.return_value.order_by.return_value.last.return_value = None
414
+ # When
415
+ with pytest.raises(SystemExit):
416
+ cli.download_audio(youtube_instance, "filetype", "target")
417
+ # Then
418
+ download.assert_not_called()
419
+
420
+
421
  @mock.patch("pytube.cli.YouTube.__init__", return_value=None)
422
  def test_perform_args_on_youtube(youtube):
423
  parser = argparse.ArgumentParser()