2
2
import pytest
3
3
4
4
from io import StringIO
5
- from unittest .mock import Mock , call
5
+ from unittest .mock import Mock
6
6
from datetime import datetime
7
7
8
8
from youtool .commands .video_search import VideoSearch
9
9
10
10
11
11
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
+ """
12
17
youtube_mock = mocker .patch ("youtool.commands.video_search.YouTube" )
13
18
expected_videos_infos = [
14
19
{
@@ -31,6 +36,11 @@ def test_video_search_string_output(mocker, videos_ids, videos_urls):
31
36
32
37
33
38
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
+ """
34
44
youtube_mock = mocker .patch ("youtool.commands.video_search.YouTube" )
35
45
expected_videos_infos = [
36
46
{
@@ -62,5 +72,13 @@ def test_video_search_file_output(mocker, videos_ids, videos_urls, tmp_path):
62
72
63
73
64
74
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
+ """
65
83
with pytest .raises (Exception , match = "Either 'ids' or 'urls' must be provided" ):
66
84
VideoSearch .execute (ids = None , urls = None )
0 commit comments