2020-04-09 19:37:49 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.peertube;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
|
|
import org.junit.jupiter.api.Test;
|
2020-12-15 15:09:49 +01:00
|
|
|
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
2022-01-04 17:28:31 +01:00
|
|
|
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
2020-04-09 19:37:49 +02:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2023-07-16 20:40:52 +02:00
|
|
|
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
|
2020-04-09 19:37:49 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
|
|
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
2020-04-10 15:40:53 +02:00
|
|
|
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeAccountExtractor;
|
2020-04-09 19:37:49 +02:00
|
|
|
|
2023-04-30 17:39:46 +02:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
2023-07-16 20:40:52 +02:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
2020-04-09 19:37:49 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
2023-08-06 13:14:51 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContain;
|
2020-04-09 19:37:49 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
|
|
|
|
|
|
|
/**
|
2020-04-10 15:40:53 +02:00
|
|
|
* Test for {@link PeertubeAccountExtractor}
|
2020-04-09 19:37:49 +02:00
|
|
|
*/
|
2020-04-10 15:40:53 +02:00
|
|
|
public class PeertubeAccountExtractorTest {
|
2021-01-11 19:44:02 +01:00
|
|
|
|
|
|
|
public static class Framasoft implements BaseChannelExtractorTest {
|
2020-04-10 15:40:53 +02:00
|
|
|
private static PeertubeAccountExtractor extractor;
|
2020-04-09 19:37:49 +02:00
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2020-04-09 19:37:49 +02:00
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
|
|
|
// 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"));
|
2020-04-10 15:40:53 +02:00
|
|
|
extractor = (PeertubeAccountExtractor) PeerTube
|
2021-01-11 19:44:02 +01:00
|
|
|
.getChannelExtractor("https://framatube.org/accounts/framasoft");
|
2020-04-09 19:37:49 +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("Framasoft", extractor.getName());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("accounts/framasoft", extractor.getId());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/accounts/framasoft", extractor.getUrl());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/accounts/framasoft", extractor.getOriginalUrl());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDescription() throws ParsingException {
|
2023-04-30 17:39:46 +02:00
|
|
|
assertNull(extractor.getDescription());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testAvatarUrl() throws ParsingException {
|
|
|
|
assertIsSecureUrl(extractor.getAvatarUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2020-10-29 19:52:29 +01:00
|
|
|
public void testBannerUrl() {
|
|
|
|
assertNull(extractor.getBannerUrl());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testFeedUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/feeds/videos.xml?accountId=3", extractor.getFeedUrl());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws ParsingException {
|
2022-01-04 17:28:31 +01:00
|
|
|
ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
2021-01-22 01:44:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testVerified() throws Exception {
|
|
|
|
assertFalse(extractor.isVerified());
|
|
|
|
}
|
2023-07-16 20:40:52 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
@Override
|
|
|
|
public void testTabs() throws Exception {
|
2023-08-06 13:14:51 +02:00
|
|
|
assertTabsContain(extractor.getTabs(), ChannelTabs.VIDEOS, ChannelTabs.CHANNELS);
|
2023-07-16 20:40:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Override
|
|
|
|
public void testTags() throws Exception {
|
|
|
|
assertTrue(extractor.getTags().isEmpty());
|
|
|
|
}
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
2021-01-11 19:44:02 +01:00
|
|
|
public static class FreeSoftwareFoundation implements BaseChannelExtractorTest {
|
2020-04-10 15:40:53 +02:00
|
|
|
private static PeertubeAccountExtractor extractor;
|
2020-04-09 19:37:49 +02:00
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2020-04-09 19:37:49 +02:00
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
|
|
|
// 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"));
|
2020-04-10 15:40:53 +02:00
|
|
|
extractor = (PeertubeAccountExtractor) PeerTube
|
2021-01-11 19:44:02 +01:00
|
|
|
.getChannelExtractor("https://framatube.org/api/v1/accounts/fsf");
|
2020-04-09 19:37:49 +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("Free Software Foundation", extractor.getName());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("accounts/fsf", extractor.getId());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/accounts/fsf", extractor.getUrl());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/api/v1/accounts/fsf", extractor.getOriginalUrl());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDescription() throws ParsingException {
|
|
|
|
assertNotNull(extractor.getDescription());
|
|
|
|
}
|
|
|
|
|
|
|
|
@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());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testFeedUrl() throws ParsingException {
|
2021-01-11 19:44:02 +01:00
|
|
|
assertEquals("https://framatube.org/feeds/videos.xml?accountId=8178", extractor.getFeedUrl());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws ParsingException {
|
2022-01-04 17:28:31 +01:00
|
|
|
ExtractorAsserts.assertGreaterOrEqual(100, extractor.getSubscriberCount());
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
2021-01-22 01:44:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testVerified() throws Exception {
|
|
|
|
assertFalse(extractor.isVerified());
|
|
|
|
}
|
2023-07-16 20:40:52 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
@Override
|
|
|
|
public void testTabs() throws Exception {
|
2023-08-06 13:14:51 +02:00
|
|
|
assertTabsContain(extractor.getTabs(), ChannelTabs.VIDEOS, ChannelTabs.CHANNELS);
|
2023-07-16 20:40:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Override
|
|
|
|
public void testTags() throws Exception {
|
|
|
|
assertTrue(extractor.getTags().isEmpty());
|
|
|
|
}
|
2020-04-09 19:37:49 +02:00
|
|
|
}
|
|
|
|
}
|