mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 06:10:33 +05:30
Use DownloaderFactory in YoutubeChannelExtractorTest
KurzgesagtAdditional needed to be extracted because it ran a duplicated request.
This commit is contained in:
parent
84eb4b30c9
commit
19737e06ee
@ -3,6 +3,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
||||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
@ -12,21 +13,29 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import java.io.IOException;
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor;
|
||||||
|
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems;
|
||||||
|
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ChannelExtractor}
|
* Test for {@link ChannelExtractor}
|
||||||
*/
|
*/
|
||||||
public class YoutubeChannelExtractorTest {
|
public class YoutubeChannelExtractorTest {
|
||||||
|
|
||||||
|
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/channel/";
|
||||||
|
|
||||||
public static class NotAvailable {
|
public static class NotAvailable {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() {
|
public static void setUp() throws IOException {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||||
|
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ContentNotAvailableException.class)
|
@Test(expected = ContentNotAvailableException.class)
|
||||||
@ -46,8 +55,9 @@ public class YoutubeChannelExtractorTest {
|
|||||||
|
|
||||||
public static class NotSupported {
|
public static class NotSupported {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() {
|
public static void setUp() throws IOException {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||||
|
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notSupported"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ContentNotSupportedException.class)
|
@Test(expected = ContentNotSupportedException.class)
|
||||||
@ -63,7 +73,8 @@ public class YoutubeChannelExtractorTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||||
|
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "gronkh"));
|
||||||
extractor = (YoutubeChannelExtractor) YouTube
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
.getChannelExtractor("http://www.youtube.com/user/Gronkh");
|
.getChannelExtractor("http://www.youtube.com/user/Gronkh");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
@ -153,7 +164,8 @@ public class YoutubeChannelExtractorTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||||
|
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "VSauce"));
|
||||||
extractor = (YoutubeChannelExtractor) YouTube
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
.getChannelExtractor("https://www.youtube.com/user/Vsauce");
|
.getChannelExtractor("https://www.youtube.com/user/Vsauce");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
@ -244,22 +256,13 @@ public class YoutubeChannelExtractorTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||||
|
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "kurzgesagt"));
|
||||||
extractor = (YoutubeChannelExtractor) YouTube
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
.getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
|
.getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Additional Testing
|
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetPageInNewExtractor() throws Exception {
|
|
||||||
final ChannelExtractor newExtractor = YouTube.getChannelExtractor(extractor.getUrl());
|
|
||||||
defaultTestGetPageInNewExtractor(extractor, newExtractor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Extractor
|
// Extractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
@ -341,12 +344,33 @@ public class YoutubeChannelExtractorTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class KurzgesagtAdditional {
|
||||||
|
|
||||||
|
private static YoutubeChannelExtractor extractor;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() throws Exception {
|
||||||
|
// Test is not deterministic, mocks can't be used
|
||||||
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||||
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
|
.getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPageInNewExtractor() throws Exception {
|
||||||
|
final ChannelExtractor newExtractor = YouTube.getChannelExtractor(extractor.getUrl());
|
||||||
|
defaultTestGetPageInNewExtractor(extractor, newExtractor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class CaptainDisillusion implements BaseChannelExtractorTest {
|
public static class CaptainDisillusion implements BaseChannelExtractorTest {
|
||||||
private static YoutubeChannelExtractor extractor;
|
private static YoutubeChannelExtractor extractor;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||||
|
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "captainDisillusion"));
|
||||||
extractor = (YoutubeChannelExtractor) YouTube
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
.getChannelExtractor("https://www.youtube.com/user/CaptainDisillusion/videos");
|
.getChannelExtractor("https://www.youtube.com/user/CaptainDisillusion/videos");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
@ -435,7 +459,8 @@ public class YoutubeChannelExtractorTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||||
|
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "random"));
|
||||||
extractor = (YoutubeChannelExtractor) YouTube
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
.getChannelExtractor("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w");
|
.getChannelExtractor("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
|
Loading…
Reference in New Issue
Block a user