Skip to content

Commit 8c4644b

Browse files
committed
add docstrings
1 parent 2fb69c0 commit 8c4644b

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

tests/commands/test_channel_info.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import pytest
1+
from unittest.mock import Mock, call
22

3-
from unittest.mock import patch, Mock, call
4-
5-
from youtool.commands.channel_info import ChannelInfo, YouTube
3+
from youtool.commands.channel_info import ChannelInfo
64

75

86
def test_filter_fields():
7+
"""Test to verify the filtering of channel information fields.
8+
9+
This test checks if the `filter_fields` method of the `ChannelInfo` class correctly
10+
filters out unwanted fields from the channel information dictionary based on the provided columns.
11+
"""
912
channel_info = {
1013
'channel_id': '123456',
1114
'channel_name': 'Test Channel',
@@ -27,6 +30,11 @@ def test_filter_fields():
2730

2831

2932
def test_channel_ids_from_urls_and_usernames(mocker):
33+
"""Test to verify fetching channel IDs from both URLs and usernames.
34+
35+
This test checks if the `execute` method of the `ChannelInfo` class correctly fetches channel IDs
36+
from a list of URLs and usernames, and then calls the `channels_infos` method with these IDs.
37+
"""
3038
urls = ["https://www.youtube.com/@Turicas/featured", "https://www.youtube.com/c/PythonicCaf%C3%A9"]
3139
usernames = ["Turicas", "PythonicCafe"]
3240

youtool/commands/channel_info.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99

1010
class ChannelInfo(Command):
11-
"""
12-
Get channel info from a list of IDs (or CSV filename with IDs inside), generate CSV output
11+
"""Get channel info from a list of IDs (or CSV filename with IDs inside), generate CSV output
1312
(same schema for `channel` dicts)
1413
"""
1514
name = "channel-info"
@@ -35,8 +34,7 @@ class ChannelInfo(Command):
3534

3635
@staticmethod
3736
def filter_fields(channel_info: Dict, info_columns: Optional[List] = None):
38-
"""
39-
Filters the fields of a dictionary containing channel information based on
37+
"""Filters the fields of a dictionary containing channel information based on
4038
specified columns.
4139
4240
Args:
@@ -55,8 +53,8 @@ def filter_fields(channel_info: Dict, info_columns: Optional[List] = None):
5553

5654
@classmethod
5755
def execute(cls: Self, **kwargs) -> str:
58-
"""
59-
Execute the channel-info command to fetch YouTube channel information from URLs or usernames and save them to a CSV file.
56+
"""Execute the channel-info command to fetch YouTube channel information from URLs or
57+
usernames and save them to a CSV file.
6058
6159
Args:
6260
urls (list[str], optional): A list of YouTube channel URLs. If not provided, `urls_file_path` must be specified.
@@ -69,7 +67,8 @@ def execute(cls: Self, **kwargs) -> str:
6967
Default is "channel_url".
7068
username_column_name (str, optional): The name of the column in the `usernames_file_path` CSV file that contains the usernames.
7169
Default is "channel_username".
72-
info_columns (str, optional): Comma-separated list of columns to include in the output CSV. Default is the class attribute `INFO_COLUMNS`.
70+
info_columns (str, optional): Comma-separated list of columns to include in the output CSV.
71+
Default is the class attribute `INFO_COLUMNS`.
7372
7473
Returns:
7574
str: A message indicating the result of the command. If `output_file_path` is specified, the message will
@@ -78,6 +77,7 @@ def execute(cls: Self, **kwargs) -> str:
7877
Raises:
7978
Exception: If neither `urls`, `usernames`, `urls_file_path` nor `usernames_file_path` is provided.
8079
"""
80+
8181
urls = kwargs.get("urls")
8282
usernames = kwargs.get("usernames")
8383
urls_file_path = kwargs.get("urls_file_path")

0 commit comments

Comments
 (0)