mirror of
https://github.com/TeamNewPipe/NewPipeExtractor
synced 2024-12-01 22:43:27 +01:00
[Bandcamp] Implement link handlers and channels tabs and tags changes on tests
Tests in BandcampChannelExtractorTest and BandcampChannelLinkHandlerFactoryTest have been also fixed. Co-authored-by: ThetaDev <t.testboy@gmail.com>
This commit is contained in:
parent
e0ba29cd19
commit
8baec04611
@ -7,12 +7,11 @@ 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.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContained;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
|
||||
public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
||||
@ -27,12 +26,7 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLength() throws ExtractionException, IOException {
|
||||
assertTrue(extractor.getInitialPage().getItems().size() >= 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testDescription() throws Exception {
|
||||
assertEquals("making music:)", extractor.getDescription());
|
||||
}
|
||||
@ -62,16 +56,6 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
||||
assertFalse(extractor.isVerified());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testRelatedItems() throws Exception {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
|
||||
@ -84,7 +68,7 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
||||
|
||||
@Override
|
||||
public void testId() throws Exception {
|
||||
assertEquals("https://toupie.bandcamp.com/", extractor.getId());
|
||||
assertEquals("2450875064", extractor.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -96,4 +80,16 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTabs() throws Exception {
|
||||
assertTabsContained(extractor.getTabs(), ChannelTabs.ALBUMS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTags() throws Exception {
|
||||
assertTrue(extractor.getTags().isEmpty());
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class BandcampChannelLinkHandlerFactoryTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
linkHandler = new BandcampChannelLinkHandlerFactory();
|
||||
linkHandler = BandcampChannelLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class BandcampChannelLinkHandlerFactoryTest {
|
||||
public void testGetId() throws ParsingException {
|
||||
assertEquals("1196681540", linkHandler.getId("https://macbenson.bandcamp.com/"));
|
||||
assertEquals("1196681540", linkHandler.getId("http://macbenson.bandcamp.com/"));
|
||||
assertEquals("1581461772", linkHandler.getId("https://interovgm.bandcamp.com/releases"));
|
||||
assertEquals("1581461772", linkHandler.getId("https://shirakumon.bandcamp.com/releases"));
|
||||
assertEquals("3321800855", linkHandler.getId("https://infiniteammo.bandcamp.com/"));
|
||||
assertEquals("3775652329", linkHandler.getId("https://npet.bandcamp.com/"));
|
||||
|
||||
@ -67,7 +67,7 @@ public class BandcampChannelLinkHandlerFactoryTest {
|
||||
@Test
|
||||
public void testGetUrl() throws ParsingException {
|
||||
assertEquals("https://macbenson.bandcamp.com", linkHandler.getUrl("1196681540"));
|
||||
assertEquals("https://interovgm.bandcamp.com", linkHandler.getUrl("1581461772"));
|
||||
assertEquals("https://shirakumon.bandcamp.com", linkHandler.getUrl("1581461772"));
|
||||
assertEquals("https://infiniteammo.bandcamp.com", linkHandler.getUrl("3321800855"));
|
||||
|
||||
assertEquals("https://lobstertheremin.com", linkHandler.getUrl("2735462545"));
|
||||
@ -82,5 +82,4 @@ public class BandcampChannelLinkHandlerFactoryTest {
|
||||
public void testGetIdWithInvalidUrl() {
|
||||
assertThrows(ParsingException.class, () -> linkHandler.getUrl("https://bandcamp.com"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,128 @@
|
||||
package org.schabi.newpipe.extractor.services.bandcamp;
|
||||
|
||||
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.tabs.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelTabExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
||||
|
||||
class BandcampChannelTabExtractorTest {
|
||||
|
||||
static class Tracks implements BaseListExtractorTest {
|
||||
private static BandcampChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
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
|
||||
@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);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// Bandcamp only return a single page
|
||||
}
|
||||
}
|
||||
|
||||
static class Albums implements BaseListExtractorTest {
|
||||
private static BandcampChannelTabExtractor extractor;
|
||||
|
||||
@BeforeAll
|
||||
static void setUp() throws IOException, ExtractionException {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (BandcampChannelTabExtractor) Bandcamp
|
||||
.getChannelTabExtractorFromId("2450875064", ChannelTabs.ALBUMS);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testServiceId() {
|
||||
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals(ChannelTabs.ALBUMS, extractor.getName());
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
// Bandcamp only return a single page
|
||||
}
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ public class BandcampCommentsLinkHandlerFactoryTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
linkHandler = new BandcampCommentsLinkHandlerFactory();
|
||||
linkHandler = BandcampCommentsLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class BandcampFeaturedLinkHandlerFactoryTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
linkHandler = new BandcampFeaturedLinkHandlerFactory();
|
||||
linkHandler = BandcampFeaturedLinkHandlerFactory.getInstance();
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ public class BandcampFeaturedLinkHandlerFactoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetId() {
|
||||
public void testGetId() throws ParsingException {
|
||||
assertEquals("Featured", linkHandler.getId("http://bandcamp.com/api/mobile/24/bootstrap_data"));
|
||||
assertEquals("Featured", linkHandler.getId("https://bandcamp.com/api/mobile/24/bootstrap_data"));
|
||||
assertEquals("Radio", linkHandler.getId("http://bandcamp.com/?show=1"));
|
||||
|
@ -21,7 +21,7 @@ public class BandcampPlaylistLinkHandlerFactoryTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
linkHandler = new BandcampPlaylistLinkHandlerFactory();
|
||||
linkHandler = BandcampPlaylistLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,12 @@ public class BandcampStreamLinkHandlerFactoryTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
linkHandler = new BandcampStreamLinkHandlerFactory();
|
||||
linkHandler = BandcampStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRadioUrl() {
|
||||
public void testGetRadioUrl() throws ParsingException {
|
||||
assertEquals("https://bandcamp.com/?show=1", linkHandler.getUrl("1"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user