2018-10-11 21:10:22 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.peertube;
|
|
|
|
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.Ignore;
|
|
|
|
import org.junit.Test;
|
2020-12-15 15:09:49 +01:00
|
|
|
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
2018-10-11 21:10:22 +02:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
|
|
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
|
|
|
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelExtractor;
|
|
|
|
|
2020-02-08 23:58:46 +01:00
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
|
|
|
|
2018-10-11 21:10:22 +02:00
|
|
|
/**
|
|
|
|
* Test for {@link PeertubeChannelExtractor}
|
|
|
|
*/
|
|
|
|
public class PeertubeChannelExtractorTest {
|
2021-01-11 19:44:02 +01:00
|
|
|
|
|
|
|
public static class LaQuadratureDuNet implements BaseChannelExtractorTest {
|
2018-10-11 21:10:22 +02:00
|
|
|
private static PeertubeChannelExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
2019-11-19 22:38:17 +01:00
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
2019-03-09 19:03:51 +01:00
|
|
|
// setting instance might break test when running in parallel
|
2021-01-11 19:44:02 +01:00
|
|
|
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
2018-10-11 21:10:22 +02:00
|
|
|
extractor = (PeertubeChannelExtractor) PeerTube
|
2021-01-11 19:44:02 +01:00
|
|
|
.getChannelExtractor("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos");
|
2018-10-11 21:10:22 +02:00
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("La Quadrature du Net", extractor.getName());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("video-channels/lqdn_channel@video.lqdn.fr", extractor.getId());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr", extractor.getUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getOriginalUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestRelatedItems(extractor);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestMoreItems(extractor);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDescription() throws ParsingException {
|
|
|
|
assertNotNull(extractor.getDescription());
|
|
|
|
}
|
|
|
|
|
2020-04-13 22:33:44 +02:00
|
|
|
@Test
|
2020-05-08 16:02:59 +02:00
|
|
|
public void testParentChannelName() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("lqdn", extractor.getParentChannelName());
|
2020-04-13 22:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2020-05-08 16:02:59 +02:00
|
|
|
public void testParentChannelUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://video.lqdn.fr/accounts/lqdn", extractor.getParentChannelUrl());
|
2020-05-08 16:02:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testParentChannelAvatarUrl() throws ParsingException {
|
|
|
|
assertIsSecureUrl(extractor.getParentChannelAvatarUrl());
|
2020-04-13 22:33:44 +02:00
|
|
|
}
|
|
|
|
|
2018-10-11 21:10:22 +02:00
|
|
|
@Test
|
|
|
|
public void testAvatarUrl() throws ParsingException {
|
|
|
|
assertIsSecureUrl(extractor.getAvatarUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testBannerUrl() throws ParsingException {
|
2020-10-29 19:52:29 +01:00
|
|
|
assertNull(extractor.getBannerUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testFeedUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/feeds/videos.xml?videoChannelId=1126", extractor.getFeedUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 230);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-11 19:44:02 +01:00
|
|
|
public static class ChatSceptique implements BaseChannelExtractorTest {
|
|
|
|
|
2018-10-11 21:10:22 +02:00
|
|
|
private static PeertubeChannelExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
2019-11-19 22:38:17 +01:00
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
2019-03-09 19:03:51 +01:00
|
|
|
// setting instance might break test when running in parallel
|
2021-01-11 19:44:02 +01:00
|
|
|
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
2018-10-11 21:10:22 +02:00
|
|
|
extractor = (PeertubeChannelExtractor) PeerTube
|
2021-01-11 19:44:02 +01:00
|
|
|
.getChannelExtractor("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr");
|
2018-10-11 21:10:22 +02:00
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Additional Testing
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetPageInNewExtractor() throws Exception {
|
|
|
|
final ChannelExtractor newExtractor = PeerTube.getChannelExtractor(extractor.getUrl());
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestGetPageInNewExtractor(extractor, newExtractor);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("Chat Sceptique", extractor.getName());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("video-channels/chatsceptique@skeptikon.fr", extractor.getId());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr", extractor.getUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr", extractor.getOriginalUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestRelatedItems(extractor);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestMoreItems(extractor);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDescription() throws ParsingException {
|
|
|
|
assertNotNull(extractor.getDescription());
|
|
|
|
}
|
|
|
|
|
2020-04-13 22:33:44 +02:00
|
|
|
@Test
|
2020-05-08 16:02:59 +02:00
|
|
|
public void testParentChannelName() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("nathan", extractor.getParentChannelName());
|
2020-05-08 16:02:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testParentChannelUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://skeptikon.fr/accounts/nathan", extractor.getParentChannelUrl());
|
2020-04-13 22:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2020-05-08 16:02:59 +02:00
|
|
|
public void testParentChannelAvatarUrl() throws ParsingException {
|
|
|
|
assertIsSecureUrl(extractor.getParentChannelAvatarUrl());
|
2020-04-13 22:33:44 +02:00
|
|
|
}
|
|
|
|
|
2018-10-11 21:10:22 +02:00
|
|
|
@Test
|
|
|
|
public void testAvatarUrl() throws ParsingException {
|
|
|
|
assertIsSecureUrl(extractor.getAvatarUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testBannerUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertNull(extractor.getBannerUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testFeedUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/feeds/videos.xml?videoChannelId=137", extractor.getFeedUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 700);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|