tests: separate channel/tab tests for Peertube, Bandcamp, Soundcloud
fix: Bandcamp channel link handler factory
This commit is contained in:
parent
0e28f2b560
commit
0583515532
|
@ -81,11 +81,10 @@ public final class BandcampChannelLinkHandlerFactory extends ListLinkHandlerFact
|
|||
// Must have "releases" or "music" as segment after url or none at all
|
||||
if (splitUrl.length > 3 && !(
|
||||
splitUrl[3].equals("releases") || splitUrl[3].equals("music")
|
||||
|| (splitUrl[3].equals("album") && splitUrl.length == 4)
|
||||
|| (splitUrl.length == 4
|
||||
&& (splitUrl[3].equals("album") || splitUrl[3].equals("track")))
|
||||
)) {
|
||||
|
||||
return false;
|
||||
|
||||
} else {
|
||||
if (splitUrl[2].equals("daily.bandcamp.com")) {
|
||||
// Refuse links to daily.bandcamp.com as that is not an artist
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
package org.schabi.newpipe.extractor.services;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface BaseChannelExtractorTest extends BaseListExtractorTest {
|
||||
public interface BaseChannelExtractorTest extends BaseExtractorTest {
|
||||
@Test
|
||||
void testDescription() throws Exception;
|
||||
@Test
|
||||
void testAvatarUrl() throws Exception;
|
||||
@Test
|
||||
void testBannerUrl() throws Exception;
|
||||
@Test
|
||||
void testFeedUrl() throws Exception;
|
||||
@Test
|
||||
void testSubscriberCount() throws Exception;
|
||||
@Test
|
||||
void testVerified() throws Exception;
|
||||
@Test
|
||||
void testTabs() throws Exception;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
package org.schabi.newpipe.extractor.services;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface BaseExtractorTest {
|
||||
@Test
|
||||
void testServiceId() throws Exception;
|
||||
@Test
|
||||
void testName() throws Exception;
|
||||
@Test
|
||||
void testId() throws Exception;
|
||||
@Test
|
||||
void testUrl() throws Exception;
|
||||
@Test
|
||||
void testOriginalUrl() throws Exception;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package org.schabi.newpipe.extractor.services;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface BaseListExtractorTest extends BaseExtractorTest {
|
||||
@Test
|
||||
void testRelatedItems() throws Exception;
|
||||
@Test
|
||||
void testMoreRelatedItems() throws Exception;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.junit.jupiter.api.Test;
|
|||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
|
||||
|
@ -16,54 +15,56 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
||||
|
||||
public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
||||
|
||||
private static ChannelExtractor extractor;
|
||||
private static ChannelTabExtractor tabExtractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases");
|
||||
extractor.fetchPage();
|
||||
|
||||
tabExtractor = Bandcamp.getChannelTabExtractor(extractor.getTabs().get(0));
|
||||
tabExtractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription() throws Exception {
|
||||
assertEquals("making music:)", extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAvatarUrl() throws Exception {
|
||||
assertTrue(extractor.getAvatarUrl().contains("://f4.bcbits.com/"), "unexpected avatar URL");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testBannerUrl() throws Exception {
|
||||
assertTrue(extractor.getBannerUrl().contains("://f4.bcbits.com/"), "unexpected banner URL");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testFeedUrl() throws Exception {
|
||||
assertNull(extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubscriberCount() throws Exception {
|
||||
assertEquals(-1, extractor.getSubscriberCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testVerified() throws Exception {
|
||||
assertFalse(extractor.isVerified());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
Set<String> tabs = extractor.getTabs().stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
|
||||
|
@ -71,41 +72,32 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(tabExtractor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServiceId() {
|
||||
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
|
||||
assertEquals(Bandcamp.getServiceId(), tabExtractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals("toupie", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws Exception {
|
||||
assertEquals("2450875064", extractor.getId());
|
||||
assertEquals("2450875064", tabExtractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws Exception {
|
||||
assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
|
||||
assertEquals("https://toupie.bandcamp.com/album", tabExtractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
|
||||
assertEquals("https://toupie.bandcamp.com/album", tabExtractor.getUrl());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelTabExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -16,7 +17,65 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
|||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
||||
|
||||
public class BandcampChannelTabExtractorTest {
|
||||
public static class Albums {
|
||||
public static class Tracks implements BaseListExtractorTest {
|
||||
private static BandcampChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws IOException, ExtractionException {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (BandcampChannelTabExtractor) Bandcamp
|
||||
.getChannelTabExtractorFromId("2464198920", ChannelTabs.TRACKS);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() throws Exception {
|
||||
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals(ChannelTabs.TRACKS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.TRACKS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("2464198920", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://wintergatan.bandcamp.com/track", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://wintergatan.bandcamp.com/track", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// Bandcamp only returns a single page
|
||||
}
|
||||
}
|
||||
|
||||
public static class Albums implements BaseListExtractorTest {
|
||||
private static BandcampChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
|
@ -28,28 +87,49 @@ public class BandcampChannelTabExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals(ChannelTabs.ALBUMS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.ALBUMS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("2450875064", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://toupie.bandcamp.com/album", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://toupie.bandcamp.com/album", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// Bandcamp only returns a single page
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ import org.junit.jupiter.api.Test;
|
|||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
|
@ -18,7 +16,6 @@ import java.util.stream.Collectors;
|
|||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeAccountExtractor}
|
||||
|
@ -27,7 +24,6 @@ public class PeertubeAccountExtractorTest {
|
|||
|
||||
public static class Framasoft implements BaseChannelExtractorTest {
|
||||
private static PeertubeAccountExtractor extractor;
|
||||
private static ChannelTabExtractor tabExtractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
|
@ -37,9 +33,6 @@ public class PeertubeAccountExtractorTest {
|
|||
extractor = (PeertubeAccountExtractor) PeerTube
|
||||
.getChannelExtractor("https://framatube.org/accounts/framasoft");
|
||||
extractor.fetchPage();
|
||||
|
||||
tabExtractor = PeerTube.getChannelTabExtractor(extractor.getTabs().get(0));
|
||||
tabExtractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -47,79 +40,77 @@ public class PeertubeAccountExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("Framasoft", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("accounts/framasoft", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/accounts/framasoft", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/accounts/framasoft", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(tabExtractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(tabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ChannelExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testBannerUrl() {
|
||||
assertNull(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testFeedUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/feeds/videos.xml?accountId=3", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubscriberCount() throws ParsingException {
|
||||
ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testVerified() throws Exception {
|
||||
assertFalse(extractor.isVerified());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
Set<String> tabs = extractor.getTabs().stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
|
||||
|
@ -130,7 +121,6 @@ public class PeertubeAccountExtractorTest {
|
|||
|
||||
public static class FreeSoftwareFoundation implements BaseChannelExtractorTest {
|
||||
private static PeertubeAccountExtractor extractor;
|
||||
private static ChannelTabExtractor tabExtractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
|
@ -140,21 +130,6 @@ public class PeertubeAccountExtractorTest {
|
|||
extractor = (PeertubeAccountExtractor) PeerTube
|
||||
.getChannelExtractor("https://framatube.org/api/v1/accounts/fsf");
|
||||
extractor.fetchPage();
|
||||
|
||||
tabExtractor = PeerTube.getChannelTabExtractor(extractor.getTabs().get(0));
|
||||
tabExtractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Additional Testing
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testGetPageInNewExtractor() throws Exception {
|
||||
final ChannelExtractor newExtractor = PeerTube.getChannelExtractor(extractor.getUrl());
|
||||
newExtractor.fetchPage();
|
||||
final ChannelTabExtractor newTabExtractor = PeerTube.getChannelTabExtractor(newExtractor.getTabs().get(0));
|
||||
defaultTestGetPageInNewExtractor(tabExtractor, newTabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -162,79 +137,77 @@ public class PeertubeAccountExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("Free Software Foundation", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("accounts/fsf", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/accounts/fsf", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/api/v1/accounts/fsf", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(tabExtractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(tabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ChannelExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testBannerUrl() throws ParsingException {
|
||||
assertNull(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testFeedUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/feeds/videos.xml?accountId=8178", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubscriberCount() throws ParsingException {
|
||||
ExtractorAsserts.assertGreaterOrEqual(100, extractor.getSubscriberCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testVerified() throws Exception {
|
||||
assertFalse(extractor.isVerified());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
Set<String> tabs = extractor.getTabs().stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
|
||||
|
|
|
@ -0,0 +1,154 @@
|
|||
package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelTabExtractor;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
||||
|
||||
public class PeertubeAccountTabExtractorTest {
|
||||
public static class Videos implements BaseListExtractorTest {
|
||||
private static PeertubeChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = (PeertubeChannelTabExtractor) PeerTube
|
||||
.getChannelTabExtractorFromId("accounts/framasoft", ChannelTabs.VIDEOS);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals(ChannelTabs.VIDEOS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.VIDEOS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("accounts/framasoft", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/accounts/framasoft/videos", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/accounts/framasoft/videos", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Channels implements BaseListExtractorTest {
|
||||
private static PeertubeChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = (PeertubeChannelTabExtractor) PeerTube
|
||||
.getChannelTabExtractorFromId("accounts/framasoft", ChannelTabs.CHANNELS);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals(ChannelTabs.CHANNELS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.CHANNELS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("accounts/framasoft", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/accounts/framasoft/video-channels", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/accounts/framasoft/video-channels", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// only 1 channels page
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
|||
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
|
@ -18,7 +17,6 @@ import java.util.stream.Collectors;
|
|||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeChannelExtractor}
|
||||
|
@ -27,7 +25,6 @@ public class PeertubeChannelExtractorTest {
|
|||
|
||||
public static class LaQuadratureDuNet implements BaseChannelExtractorTest {
|
||||
private static PeertubeChannelExtractor extractor;
|
||||
private static ChannelTabExtractor tabExtractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
|
@ -37,9 +34,6 @@ public class PeertubeChannelExtractorTest {
|
|||
extractor = (PeertubeChannelExtractor) PeerTube
|
||||
.getChannelExtractor("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos");
|
||||
extractor.fetchPage();
|
||||
|
||||
tabExtractor = PeerTube.getChannelTabExtractor(extractor.getTabs().get(0));
|
||||
tabExtractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -47,46 +41,33 @@ public class PeertubeChannelExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
assertEquals(PeerTube.getServiceId(), tabExtractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("La Quadrature du Net", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("video-channels/lqdn_channel@video.lqdn.fr", extractor.getId());
|
||||
assertEquals("video-channels/lqdn_channel@video.lqdn.fr", tabExtractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr", extractor.getUrl());
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", tabExtractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getOriginalUrl());
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", tabExtractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(tabExtractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(tabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -94,6 +75,7 @@ public class PeertubeChannelExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
@ -114,31 +96,37 @@ public class PeertubeChannelExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testBannerUrl() throws ParsingException {
|
||||
assertNull(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testFeedUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/feeds/videos.xml?videoChannelId=1126", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubscriberCount() throws ParsingException {
|
||||
ExtractorAsserts.assertGreaterOrEqual(230, extractor.getSubscriberCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testVerified() throws Exception {
|
||||
assertFalse(extractor.isVerified());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
Set<String> tabs = extractor.getTabs().stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
|
||||
|
@ -149,7 +137,6 @@ public class PeertubeChannelExtractorTest {
|
|||
public static class ChatSceptique implements BaseChannelExtractorTest {
|
||||
|
||||
private static PeertubeChannelExtractor extractor;
|
||||
private static ChannelTabExtractor tabExtractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
|
@ -159,9 +146,6 @@ public class PeertubeChannelExtractorTest {
|
|||
extractor = (PeertubeChannelExtractor) PeerTube
|
||||
.getChannelExtractor("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr");
|
||||
extractor.fetchPage();
|
||||
|
||||
tabExtractor = PeerTube.getChannelTabExtractor(extractor.getTabs().get(0));
|
||||
tabExtractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -172,8 +156,6 @@ public class PeertubeChannelExtractorTest {
|
|||
public void testGetPageInNewExtractor() throws Exception {
|
||||
final ChannelExtractor newExtractor = PeerTube.getChannelExtractor(extractor.getUrl());
|
||||
newExtractor.fetchPage();
|
||||
final ChannelTabExtractor newTabExtractor = PeerTube.getChannelTabExtractor(newExtractor.getTabs().get(0));
|
||||
defaultTestGetPageInNewExtractor(tabExtractor, newTabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -181,46 +163,33 @@ public class PeertubeChannelExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
assertEquals(PeerTube.getServiceId(), tabExtractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("Chat Sceptique", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("video-channels/chatsceptique@skeptikon.fr", extractor.getId());
|
||||
assertEquals("video-channels/chatsceptique@skeptikon.fr", tabExtractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr", extractor.getUrl());
|
||||
assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr/videos", tabExtractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr", extractor.getOriginalUrl());
|
||||
assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr/videos", tabExtractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(tabExtractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(tabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -228,6 +197,7 @@ public class PeertubeChannelExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
@ -248,31 +218,37 @@ public class PeertubeChannelExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testBannerUrl() throws ParsingException {
|
||||
assertNull(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testFeedUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/feeds/videos.xml?videoChannelId=137", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubscriberCount() throws ParsingException {
|
||||
ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testVerified() throws Exception {
|
||||
assertFalse(extractor.isVerified());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
Set<String> tabs = extractor.getTabs().stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
|
||||
|
|
|
@ -4,19 +4,102 @@ import org.junit.jupiter.api.BeforeAll;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelTabExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
public class PeertubeChannelTabExtractorTest {
|
||||
public static class Playlists {
|
||||
public static class Videos implements BaseListExtractorTest {
|
||||
private static PeertubeChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = (PeertubeChannelTabExtractor) PeerTube
|
||||
.getChannelTabExtractorFromId("video-channels/lqdn_channel@video.lqdn.fr", ChannelTabs.VIDEOS);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals(ChannelTabs.VIDEOS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() throws ParsingException {
|
||||
assertEquals(ChannelTabs.VIDEOS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("video-channels/lqdn_channel@video.lqdn.fr", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Additional Testing
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testGetPageInNewExtractor() throws Exception {
|
||||
final ChannelTabExtractor newTabExtractor = PeerTube
|
||||
.getChannelTabExtractorFromId("video-channels/lqdn_channel@video.lqdn.fr", ChannelTabs.VIDEOS);
|
||||
defaultTestGetPageInNewExtractor(extractor, newTabExtractor);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Playlists implements BaseListExtractorTest {
|
||||
private static PeertubeChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
|
@ -29,32 +112,53 @@ public class PeertubeChannelTabExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals(ChannelTabs.PLAYLISTS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.PLAYLISTS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("video-channels/lqdn_channel@video.lqdn.fr", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/video-playlists", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/video-playlists", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// only 1 playlists tab
|
||||
}
|
||||
}
|
||||
|
||||
public static class Channels {
|
||||
public static class Channels implements BaseListExtractorTest {
|
||||
private static PeertubeChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
|
@ -67,28 +171,49 @@ public class PeertubeChannelTabExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals(ChannelTabs.CHANNELS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.CHANNELS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("accounts/framasoft", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://framatube.org/accounts/framasoft/video-channels", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://framatube.org/accounts/framasoft/video-channels", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// only 1 channels tab
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
|||
public class SoundcloudChannelExtractorTest {
|
||||
public static class LilUzi implements BaseChannelExtractorTest {
|
||||
private static SoundcloudChannelExtractor extractor;
|
||||
private static ChannelTabExtractor tabExtractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
|
@ -34,9 +33,6 @@ public class SoundcloudChannelExtractorTest {
|
|||
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||
.getChannelExtractor("http://soundcloud.com/liluzivert/sets");
|
||||
extractor.fetchPage();
|
||||
|
||||
tabExtractor = SoundCloud.getChannelTabExtractor(extractor.getTabs().get(0));
|
||||
tabExtractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -44,46 +40,33 @@ public class SoundcloudChannelExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
assertEquals(SoundCloud.getServiceId(), tabExtractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() {
|
||||
assertEquals("Lil Uzi Vert", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("10494998", extractor.getId());
|
||||
assertEquals("10494998", tabExtractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://soundcloud.com/liluzivert", extractor.getUrl());
|
||||
assertEquals("https://soundcloud.com/liluzivert/tracks", tabExtractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl());
|
||||
assertEquals("http://soundcloud.com/liluzivert/tracks", tabExtractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(tabExtractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(tabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -91,36 +74,43 @@ public class SoundcloudChannelExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription() {
|
||||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAvatarUrl() {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testBannerUrl() {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testFeedUrl() {
|
||||
assertEmpty(extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubscriberCount() {
|
||||
assertTrue(extractor.getSubscriberCount() >= 1e6, "Wrong subscriber count");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testVerified() throws Exception {
|
||||
assertTrue(extractor.isVerified());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
Set<String> tabs = extractor.getTabs().stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
|
||||
|
@ -132,7 +122,6 @@ public class SoundcloudChannelExtractorTest {
|
|||
|
||||
public static class DubMatix implements BaseChannelExtractorTest {
|
||||
private static SoundcloudChannelExtractor extractor;
|
||||
private static ChannelTabExtractor tabExtractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
|
@ -140,21 +129,6 @@ public class SoundcloudChannelExtractorTest {
|
|||
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||
.getChannelExtractor("https://soundcloud.com/dubmatix");
|
||||
extractor.fetchPage();
|
||||
|
||||
tabExtractor = SoundCloud.getChannelTabExtractor(extractor.getTabs().get(0));
|
||||
tabExtractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Additional Testing
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testGetPageInNewExtractor() throws Exception {
|
||||
final ChannelExtractor newExtractor = SoundCloud.getChannelExtractor(extractor.getUrl());
|
||||
newExtractor.fetchPage();
|
||||
final ChannelTabExtractor newTabExtractor = SoundCloud.getChannelTabExtractor(newExtractor.getTabs().get(0));
|
||||
defaultTestGetPageInNewExtractor(tabExtractor, newTabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -162,81 +136,77 @@ public class SoundcloudChannelExtractorTest {
|
|||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
assertEquals(SoundCloud.getServiceId(), tabExtractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("dubmatix", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("542134", extractor.getId());
|
||||
assertEquals("542134", tabExtractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://soundcloud.com/dubmatix", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://soundcloud.com/dubmatix", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(tabExtractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(tabExtractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ChannelExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription() {
|
||||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAvatarUrl() {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testBannerUrl() {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testFeedUrl() {
|
||||
assertEmpty(extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubscriberCount() {
|
||||
assertTrue(extractor.getSubscriberCount() >= 2e6, "Wrong subscriber count");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testVerified() throws Exception {
|
||||
assertTrue(extractor.isVerified());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
Set<String> tabs = extractor.getTabs().stream()
|
||||
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
|
||||
|
|
|
@ -4,20 +4,92 @@ import org.junit.jupiter.api.BeforeAll;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelTabExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
public class SoundcloudChannelTabExtractorTest {
|
||||
public static class Playlists {
|
||||
public static class Tracks implements BaseListExtractorTest {
|
||||
private static SoundcloudChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws IOException, ExtractionException {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudChannelTabExtractor) SoundCloud
|
||||
.getChannelTabExtractorFromId("10494998", ChannelTabs.TRACKS);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() throws Exception {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals(ChannelTabs.TRACKS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.TRACKS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws Exception {
|
||||
assertEquals("10494998", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/liluzivert/tracks", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/liluzivert/tracks", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Additional Testing
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testGetPageInNewExtractor() throws Exception {
|
||||
final ChannelTabExtractor newTabExtractor =
|
||||
SoundCloud.getChannelTabExtractorFromId("10494998", ChannelTabs.TRACKS);
|
||||
defaultTestGetPageInNewExtractor(extractor, newTabExtractor);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Playlists implements BaseListExtractorTest {
|
||||
private static SoundcloudChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
|
@ -29,37 +101,54 @@ public class SoundcloudChannelTabExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals(ChannelTabs.PLAYLISTS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.PLAYLISTS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("323371733", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://soundcloud.com/trackaholic/sets", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/trackaholic/sets", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Albums {
|
||||
public static class Albums implements BaseListExtractorTest {
|
||||
private static SoundcloudChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
|
@ -71,31 +160,48 @@ public class SoundcloudChannelTabExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals(ChannelTabs.ALBUMS, extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTab() {
|
||||
assertEquals(ChannelTabs.ALBUMS, extractor.getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("4803918", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://soundcloud.com/bigsean-1/albums", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://soundcloud.com/bigsean-1/albums", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue