def test_download_by_resolution(download, stream, stream_query, youtube): # Given stream_query.get_by_resolution.return_value = stream youtube.streams = stream_query # When cli.download_by_resolution(youtube=youtube, resolution="320p", target="test_target") # Then download.assert_called_with(stream, target="test_target")
def test_download_by_resolution_not_exists(download, stream_query, youtube): stream_query.get_by_resolution.return_value = None youtube.streams = stream_query with pytest.raises(SystemExit): cli.download_by_resolution(youtube=youtube, resolution="DOESNT EXIST", target="test_target") download.assert_not_called()
def test_download_by_resolution(youtube, stream_query, stream): stream_query.get_by_resolution.return_value = stream youtube.streams = stream_query cli._download = MagicMock() cli.download_by_resolution(youtube=youtube, resolution="320p", target="test_target") cli._download.assert_called_with(stream, target="test_target")