Example #1
0
def test_download_caption_with_language_found(youtube):
    youtube.title = "video title"
    caption = Caption(
        {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en"}
    )
    caption.download = MagicMock(return_value="file_path")
    youtube.captions = CaptionQuery([caption])
    cli.download_caption(youtube, "en")
    caption.download.assert_called_with(title="video title", output_path=None)
Example #2
0
def test_download_caption_with_lang_not_found(youtube, print_available):
    # Given
    caption = Caption(
        {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en"}
    )
    youtube.captions = CaptionQuery([caption])
    # When
    cli.download_caption(youtube, "blah")
    # Then
    print_available.assert_called_with(youtube.captions)
Example #3
0
def test_download_caption_with_language_not_found(youtube):
    caption = Caption({
        "url": "url1",
        "name": {
            "simpleText": "name1"
        },
        "languageCode": "en"
    })
    youtube.captions = CaptionQuery([caption])
    with patch.object(youtube.captions, "all",
                      wraps=youtube.captions.all) as wrapped_all:
        cli.download_caption(youtube, "blah")
        wrapped_all.assert_called()