mirror of
https://github.com/hwchase17/langchain
synced 2024-11-18 09:25:54 +00:00
00c6ec8a2d
# Fix Telegram API loader + add tests. I was testing this integration and it was broken with next error: ```python message_threads = loader._get_message_threads(df) KeyError: False ``` Also, this particular loader didn't have any tests / related group in poetry, so I added those as well. @hwchase17 / @eyurtsev please take a look on this fix PR. --------- Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
28 lines
1.3 KiB
Python
28 lines
1.3 KiB
Python
import pytest
|
|
|
|
from langchain.document_loaders import YoutubeLoader
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"youtube_url, expected_video_id",
|
|
[
|
|
("http://www.youtube.com/watch?v=-wtIMTCHWuI", "-wtIMTCHWuI"),
|
|
("http://youtube.com/watch?v=-wtIMTCHWuI", "-wtIMTCHWuI"),
|
|
("http://m.youtube.com/watch?v=-wtIMTCHWuI", "-wtIMTCHWuI"),
|
|
("http://youtu.be/-wtIMTCHWuI", "-wtIMTCHWuI"),
|
|
("https://youtu.be/-wtIMTCHWuI", "-wtIMTCHWuI"),
|
|
("https://www.youtube.com/watch?v=lalOy8Mbfdc", "lalOy8Mbfdc"),
|
|
("https://m.youtube.com/watch?v=lalOy8Mbfdc", "lalOy8Mbfdc"),
|
|
("https://youtube.com/watch?v=lalOy8Mbfdc", "lalOy8Mbfdc"),
|
|
("http://youtu.be/lalOy8Mbfdc?t=1", "lalOy8Mbfdc"),
|
|
("http://youtu.be/lalOy8Mbfdc?t=1s", "lalOy8Mbfdc"),
|
|
("https://youtu.be/lalOy8Mbfdc?t=1", "lalOy8Mbfdc"),
|
|
("http://www.youtube-nocookie.com/embed/lalOy8Mbfdc?rel=0", "lalOy8Mbfdc"),
|
|
("https://youtu.be/lalOy8Mbfdc?t=1s", "lalOy8Mbfdc"),
|
|
("https://www.youtube.com/shorts/cd0Fy92_w_s", "cd0Fy92_w_s"),
|
|
],
|
|
)
|
|
def test_video_id_extraction(youtube_url: str, expected_video_id: str) -> None:
|
|
"""Test that the video id is extracted from a youtube url"""
|
|
assert YoutubeLoader.extract_video_id(youtube_url) == expected_video_id
|