Skip to content

Commit ad3d187

Browse files
committed
[YouTube] Fix testRelatedItems method of YoutubeStreamExtractorRelatedMixTest
This commit fixes the testRelatedItems test method by: - accepting consent in the test class, in order to extract mixes in recommendations; - removing assertion of a music mix inside the recommendations, as YouTube doesn't seem to return such mixes anymore, at least for the video used in the test class.
1 parent e111814 commit ad3d187

1 file changed

Lines changed: 4 additions & 15 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorRelatedMixTest.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import static org.junit.jupiter.api.Assertions.assertNotEquals;
55
import static org.junit.jupiter.api.Assertions.assertSame;
66
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContains;
7+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertGreaterOrEqual;
78
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
89
import static org.schabi.newpipe.extractor.services.youtube.stream.YoutubeStreamExtractorDefaultTest.YOUTUBE_LICENCE;
910

1011
import org.junit.jupiter.api.BeforeAll;
11-
import org.junit.jupiter.api.Disabled;
1212
import org.junit.jupiter.api.Test;
1313
import org.schabi.newpipe.downloader.DownloaderFactory;
1414
import org.schabi.newpipe.extractor.InfoItem;
@@ -17,6 +17,7 @@
1717
import org.schabi.newpipe.extractor.playlist.PlaylistInfo.PlaylistType;
1818
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
1919
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
20+
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
2021
import org.schabi.newpipe.extractor.services.youtube.YoutubeTestsUtils;
2122
import org.schabi.newpipe.extractor.stream.StreamExtractor;
2223
import org.schabi.newpipe.extractor.stream.StreamType;
@@ -38,6 +39,7 @@ public class YoutubeStreamExtractorRelatedMixTest extends DefaultStreamExtractor
3839
@BeforeAll
3940
public static void setUp() throws Exception {
4041
YoutubeTestsUtils.ensureStateless();
42+
YoutubeParsingHelper.setConsentAccepted(true);
4143
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "relatedMix"));
4244
extractor = YouTube.getStreamExtractor(URL);
4345
extractor.fetchPage();
@@ -80,7 +82,6 @@ public static void setUp() throws Exception {
8082
// @formatter:on
8183

8284
@Test
83-
@Disabled("Mixes are not available in related items anymore, see https://github.com/TeamNewPipe/NewPipeExtractor/issues/820")
8485
@Override
8586
public void testRelatedItems() throws Exception {
8687
super.testRelatedItems();
@@ -97,7 +98,7 @@ public void testRelatedItems() throws Exception {
9798
final List<PlaylistInfoItem> streamMixes = playlists.stream()
9899
.filter(item -> item.getPlaylistType().equals(PlaylistType.MIX_STREAM))
99100
.collect(Collectors.toList());
100-
assertEquals(1, streamMixes.size(), "Not found exactly one stream mix in related items");
101+
assertGreaterOrEqual(1, streamMixes.size(), "Not found one or more stream mix in related items");
101102

102103
final PlaylistInfoItem streamMix = streamMixes.get(0);
103104
assertSame(InfoItem.InfoType.PLAYLIST, streamMix.getInfoType());
@@ -106,17 +107,5 @@ public void testRelatedItems() throws Exception {
106107
assertContains("list=RD" + ID, streamMix.getUrl());
107108
assertEquals("Mix – " + TITLE, streamMix.getName());
108109
YoutubeTestsUtils.testImages(streamMix.getThumbnails());
109-
110-
final List<PlaylistInfoItem> musicMixes = playlists.stream()
111-
.filter(item -> item.getPlaylistType().equals(PlaylistType.MIX_MUSIC))
112-
.collect(Collectors.toList());
113-
assertEquals(1, musicMixes.size(), "Not found exactly one music mix in related items");
114-
115-
final PlaylistInfoItem musicMix = musicMixes.get(0);
116-
assertSame(InfoItem.InfoType.PLAYLIST, musicMix.getInfoType());
117-
assertEquals(YouTube.getServiceId(), musicMix.getServiceId());
118-
assertContains("list=RDCLAK", musicMix.getUrl());
119-
assertEquals("Hip Hop Essentials", musicMix.getName());
120-
YoutubeTestsUtils.testImages(musicMix.getThumbnails());
121110
}
122111
}

0 commit comments

Comments
 (0)