2018-10-11 21:10:22 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.peertube;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for {@link PeertubeChannelExtractor}
|
|
|
|
*/
|
|
|
|
public class PeertubeChannelExtractorTest {
|
2019-11-15 19:37:45 +01:00
|
|
|
public static class KDE 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
|
2019-11-15 19:37:45 +01:00
|
|
|
.getChannelExtractor("https://peertube.mastodon.host/api/v1/accounts/kde");
|
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 {
|
2019-11-15 19:37:45 +01:00
|
|
|
assertEquals("The KDE Community", extractor.getName());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws ParsingException {
|
2019-11-15 19:37:45 +01:00
|
|
|
assertEquals("kde", extractor.getId());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
2019-11-15 19:37:45 +01:00
|
|
|
assertEquals("https://peertube.mastodon.host/api/v1/accounts/kde", extractor.getUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2019-11-15 22:12:39 +01:00
|
|
|
assertEquals("https://peertube.mastodon.host/accounts/kde", extractor.getOriginalUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
|
|
|
defaultTestRelatedItems(extractor, PeerTube.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
|
|
|
defaultTestMoreItems(extractor, PeerTube.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDescription() throws ParsingException {
|
|
|
|
assertNotNull(extractor.getDescription());
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 {
|
|
|
|
assertEmpty(extractor.getFeedUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws ParsingException {
|
|
|
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 19:37:45 +01:00
|
|
|
public static class Booteille 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
|
2019-11-15 19:37:45 +01:00
|
|
|
.getChannelExtractor("https://peertube.mastodon.host/accounts/booteille");
|
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());
|
|
|
|
defaultTestGetPageInNewExtractor(extractor, newExtractor, PeerTube.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws ParsingException {
|
2019-11-15 19:37:45 +01:00
|
|
|
assertEquals("booteille", extractor.getName());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws ParsingException {
|
2019-11-15 19:37:45 +01:00
|
|
|
assertEquals("booteille", extractor.getId());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
2019-11-15 19:37:45 +01:00
|
|
|
assertEquals("https://peertube.mastodon.host/api/v1/accounts/booteille", extractor.getUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2019-11-15 19:37:45 +01:00
|
|
|
assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getOriginalUrl());
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
|
|
|
defaultTestRelatedItems(extractor, PeerTube.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
|
|
|
defaultTestMoreItems(extractor, PeerTube.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDescription() throws ParsingException {
|
|
|
|
assertNotNull(extractor.getDescription());
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 {
|
|
|
|
assertEmpty(extractor.getFeedUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws ParsingException {
|
2020-02-08 23:08:37 +01:00
|
|
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 1);
|
2018-10-11 21:10:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|