Skip to content

Commit 0986b75

Browse files
committed
add docstrings
1 parent 4eae14c commit 0986b75

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tests/commands/test_video_search.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
import pytest
33

44
from io import StringIO
5-
from unittest.mock import Mock, call
5+
from unittest.mock import Mock
66
from datetime import datetime
77

88
from youtool.commands.video_search import VideoSearch
99

1010

1111
def test_video_search_string_output(mocker, videos_ids, videos_urls):
12+
"""Test the execution of the video-search command and verify the output as string.
13+
14+
This test simulates the execution of the `VideoSearch.execute` command with a list of video IDs and URLs,
15+
and checks if the output is correctly formatted as a CSV string.
16+
"""
1217
youtube_mock = mocker.patch("youtool.commands.video_search.YouTube")
1318
expected_videos_infos = [
1419
{
@@ -31,6 +36,11 @@ def test_video_search_string_output(mocker, videos_ids, videos_urls):
3136

3237

3338
def test_video_search_file_output(mocker, videos_ids, videos_urls, tmp_path):
39+
"""Test the execution of the video-search command and verify the output to a file.
40+
41+
This test simulates the execution of the `VideoSearch.execute` command with a list of video IDs and URLs,
42+
and checks if the output is correctly written to a CSV file.
43+
"""
3444
youtube_mock = mocker.patch("youtool.commands.video_search.YouTube")
3545
expected_videos_infos = [
3646
{
@@ -62,5 +72,13 @@ def test_video_search_file_output(mocker, videos_ids, videos_urls, tmp_path):
6272

6373

6474
def test_video_search_no_id_and_url_error():
75+
"""Test if the video-search command raises an exception when neither IDs nor URLs are provided.
76+
77+
This test checks if executing the `VideoSearch.execute` command without providing IDs or URLs
78+
raises the expected exception.
79+
80+
Assertions:
81+
- Assert that the raised exception matches the expected error message.
82+
"""
6583
with pytest.raises(Exception, match="Either 'ids' or 'urls' must be provided"):
6684
VideoSearch.execute(ids=None, urls=None)

youtool/commands/video_search.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ def execute(cls: Self, **kwargs) -> str:
4444
output_file_path (str, optional): Path to the output CSV file where video information will be saved.
4545
api_key (str): The API key to authenticate with the YouTube Data API.
4646
full_info (bool, optional): Flag to indicate whether to get full video info. Default is False.
47+
url_column_name (str, optional): The name of the column in the input CSV file that contains the URLs. Default is "video_url".
48+
id_column_name (str, optional): The name of the column in the input CSV file that contains the IDs. Default is "video_id".
4749
4850
Returns:
49-
A message indicating the result of the command. If output_file_path is specified,
51+
str: A message indicating the result of the command. If output_file_path is specified,
5052
the message will include the path to the generated CSV file.
5153
Otherwise, it will return the result as a string.
5254

0 commit comments

Comments
 (0)