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;
|
2019-11-19 22:38:17 +01:00
|
|
|
import org.schabi.newpipe.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 {
|
2020-04-09 19:37:49 +02:00
|
|
|
public static class DanDAugeTutoriels 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
|
2019-11-22 18:29:14 +01:00
|
|
|
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
2018-10-11 21:10:22 +02:00
|
|
|
extractor = (PeertubeChannelExtractor) PeerTube
|
2020-04-11 17:42:15 +02:00
|
|
|
.getChannelExtractor("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa");
|
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 {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertEquals("Dan d'Auge tutoriels", extractor.getName());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws ParsingException {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertEquals("video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getId());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
2020-04-09 19:46:20 +02:00
|
|
|
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", 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 {
|
|
|
|
assertEquals("libux", extractor.getParentChannelName());
|
2020-04-13 22:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2020-05-08 16:02:59 +02:00
|
|
|
public void testParentChannelUrl() throws ParsingException {
|
|
|
|
assertEquals("https://peertube.mastodon.host/accounts/libux", extractor.getParentChannelUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@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());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Ignore
|
|
|
|
@Test
|
|
|
|
public void testBannerUrl() throws ParsingException {
|
|
|
|
assertIsSecureUrl(extractor.getBannerUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testFeedUrl() throws ParsingException {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?videoChannelId=1361", extractor.getFeedUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws ParsingException {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 4);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-09 19:37:49 +02:00
|
|
|
public static class Divers 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
|
2019-11-22 18:29:14 +01:00
|
|
|
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
2018-10-11 21:10:22 +02:00
|
|
|
extractor = (PeertubeChannelExtractor) PeerTube
|
2020-04-09 19:46:20 +02:00
|
|
|
.getChannelExtractor("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457");
|
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 {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertEquals("Divers", extractor.getName());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws ParsingException {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertEquals("video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getId());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
2020-04-09 19:46:20 +02:00
|
|
|
assertEquals("https://peertube.mastodon.host/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2020-04-09 19:46:20 +02:00
|
|
|
assertEquals("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", 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 {
|
|
|
|
assertEquals("booteille", extractor.getParentChannelName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testParentChannelUrl() throws ParsingException {
|
|
|
|
assertEquals("https://peertube.mastodon.host/accounts/booteille", 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());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Ignore
|
|
|
|
@Test
|
|
|
|
public void testBannerUrl() throws ParsingException {
|
|
|
|
assertIsSecureUrl(extractor.getBannerUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testFeedUrl() throws ParsingException {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?videoChannelId=1227", extractor.getFeedUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws ParsingException {
|
2020-04-09 19:37:49 +02:00
|
|
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 2);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|