[Bandcamp] Add comments (first page)
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package org.schabi.newpipe.extractor.services.bandcamp;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.services.DefaultTests;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class BandcampCommentsExtractorTest {
|
||||
|
||||
private static CommentsExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws ExtractionException, IOException {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = Bandcamp.getCommentsExtractor("https://floatingpoints.bandcamp.com/album/promises");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasComments() throws IOException, ExtractionException {
|
||||
assertTrue(extractor.getInitialPage().getItems().size() >= 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommentsAllData() throws IOException, ExtractionException {
|
||||
ListExtractor.InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
|
||||
|
||||
DefaultTests.defaultTestListOfItems(Bandcamp, comments.getItems(), comments.getErrors());
|
||||
for (CommentsInfoItem c : comments.getItems()) {
|
||||
assertFalse(Utils.isBlank(c.getUploaderUrl()));
|
||||
assertFalse(Utils.isBlank(c.getUploaderName()));
|
||||
assertFalse(Utils.isBlank(c.getUploaderAvatarUrl()));
|
||||
assertFalse(Utils.isBlank(c.getCommentText()));
|
||||
assertFalse(Utils.isBlank(c.getName()));
|
||||
assertFalse(Utils.isBlank(c.getThumbnailUrl()));
|
||||
assertFalse(Utils.isBlank(c.getUrl()));
|
||||
assertEquals(-1, c.getLikeCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later
|
||||
|
||||
package org.schabi.newpipe.extractor.services.bandcamp;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.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.services.bandcamp.linkHandler.BandcampCommentsLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampStreamLinkHandlerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test for {@link BandcampCommentsLinkHandlerFactory}
|
||||
*/
|
||||
public class BandcampCommentsLinkHandlerFactoryTest {
|
||||
|
||||
private static BandcampCommentsLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = new BandcampCommentsLinkHandlerFactory();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptUrl() throws ParsingException {
|
||||
assertFalse(linkHandler.acceptUrl("http://interovgm.com/releases/"));
|
||||
assertFalse(linkHandler.acceptUrl("https://interovgm.com/releases"));
|
||||
assertFalse(linkHandler.acceptUrl("http://zachbenson.bandcamp.com"));
|
||||
assertFalse(linkHandler.acceptUrl("https://bandcamp.com"));
|
||||
assertFalse(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/"));
|
||||
assertFalse(linkHandler.acceptUrl("https://example.com/track/sampletrack"));
|
||||
assertFalse(linkHandler.acceptUrl("http://bandcamP.com/?show=38"));
|
||||
|
||||
assertTrue(linkHandler.acceptUrl("https://powertothequeerkids.bandcamp.com/album/power-to-the-queer-kids"));
|
||||
assertTrue(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/track/kitchen"));
|
||||
assertTrue(linkHandler.acceptUrl("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/"));
|
||||
assertTrue(linkHandler.acceptUrl("https://interovgm.bandcamp.com/track/title"));
|
||||
assertTrue(linkHandler.acceptUrl("https://goodgoodblood-tl.bandcamp.com/track/when-it-all-wakes-up"));
|
||||
assertTrue(linkHandler.acceptUrl("https://lobstertheremin.com/track/unfinished"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user