@@ -427,16 +427,50 @@ def test_youtube_channel_videos(client: Supadata, requests_mock) -> None:
427427 "videoIds" : [
428428 "PQ2WjtaPfXU" ,
429429 "UIVADiGfwWc" ,
430+ ],
431+ "shortIds" : [
432+ "abc123" ,
433+ "def456" ,
430434 ]
431435 }
432436
433437 requests_mock .get (
434- f"{ client .base_url } /youtube/channel/videos?id={ channel_id } " , json = mock_response
438+ f"{ client .base_url } /youtube/channel/videos?id={ channel_id } &type=all " , json = mock_response
435439 )
436440 channel_videos = client .youtube .channel .videos (channel_id )
437- assert isinstance (channel_videos , list )
438- assert len (channel_videos ) == len (mock_response ["videoIds" ])
439- for i in channel_videos :
441+ assert hasattr (channel_videos , "video_ids" )
442+ assert hasattr (channel_videos , "short_ids" )
443+ assert isinstance (channel_videos .video_ids , list )
444+ assert isinstance (channel_videos .short_ids , list )
445+ assert len (channel_videos .video_ids ) == len (mock_response ["videoIds" ])
446+ assert len (channel_videos .short_ids ) == len (mock_response ["shortIds" ])
447+ for i in channel_videos .video_ids :
448+ assert i in mock_response ["videoIds" ]
449+ for i in channel_videos .short_ids :
450+ assert i in mock_response ["shortIds" ]
451+
452+
453+ def test_youtube_channel_videos_with_type (client : Supadata , requests_mock ) -> None :
454+ channel_id = "UCsBjURrPoezyLs9EqgamOA"
455+ mock_response = {
456+ "videoIds" : [
457+ "PQ2WjtaPfXU" ,
458+ "UIVADiGfwWc" ,
459+ ],
460+ "shortIds" : []
461+ }
462+
463+ requests_mock .get (
464+ f"{ client .base_url } /youtube/channel/videos?id={ channel_id } &type=video" , json = mock_response
465+ )
466+ channel_videos = client .youtube .channel .videos (channel_id , type = "video" )
467+ assert hasattr (channel_videos , "video_ids" )
468+ assert hasattr (channel_videos , "short_ids" )
469+ assert isinstance (channel_videos .video_ids , list )
470+ assert isinstance (channel_videos .short_ids , list )
471+ assert len (channel_videos .video_ids ) == len (mock_response ["videoIds" ])
472+ assert len (channel_videos .short_ids ) == 0
473+ for i in channel_videos .video_ids :
440474 assert i in mock_response ["videoIds" ]
441475
442476
@@ -448,7 +482,7 @@ def test_youtube_channel_videos_invalid_id(client: Supadata, requests_mock) -> N
448482 "details" : "The requested item could not be found." ,
449483 }
450484 requests_mock .get (
451- f"{ client .base_url } /youtube/channel/videos?id={ channel_id } " ,
485+ f"{ client .base_url } /youtube/channel/videos?id={ channel_id } &type=all " ,
452486 status_code = 404 ,
453487 json = mock_response ,
454488 )
@@ -468,6 +502,10 @@ def test_youtube_playlist_videos(client: Supadata, requests_mock) -> None:
468502 "videoIds" : [
469503 "zDNaUi2cjv4" ,
470504 "B1t4Fjlomi8" ,
505+ ],
506+ "shortIds" : [
507+ "short1" ,
508+ "short2"
471509 ]
472510 }
473511 requests_mock .get (
@@ -476,10 +514,16 @@ def test_youtube_playlist_videos(client: Supadata, requests_mock) -> None:
476514 )
477515
478516 playlist_videos = client .youtube .playlist .videos (playlist_id )
479- assert isinstance (playlist_videos , list )
480- assert len (playlist_videos ) == len (mock_response ["videoIds" ])
481- for i in playlist_videos :
517+ assert hasattr (playlist_videos , "video_ids" )
518+ assert hasattr (playlist_videos , "short_ids" )
519+ assert isinstance (playlist_videos .video_ids , list )
520+ assert isinstance (playlist_videos .short_ids , list )
521+ assert len (playlist_videos .video_ids ) == len (mock_response ["videoIds" ])
522+ assert len (playlist_videos .short_ids ) == len (mock_response ["shortIds" ])
523+ for i in playlist_videos .video_ids :
482524 assert i in mock_response ["videoIds" ]
525+ for i in playlist_videos .short_ids :
526+ assert i in mock_response ["shortIds" ]
483527
484528
485529def test_youtube_playlist_videos_invalid_id (client : Supadata , requests_mock ) -> None :
0 commit comments