mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-29 00:10:35 +05:30
[Bandcamp] Apply changes in extractor tests
Also remove some public test methods modifiers, add missing Test annotations on old Junit 4 tests (and update them if needed), and use final in some places where it was possible. BandcampChannelExtractorTest.testLength has been removed as the test is always true.
This commit is contained in:
parent
2578f22054
commit
0292c4f3e8
@ -10,7 +10,10 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContain;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
|
||||
@ -31,51 +34,61 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
||||
assertEquals("making music:)", extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAvatarUrl() throws Exception {
|
||||
assertTrue(extractor.getAvatarUrl().contains("://f4.bcbits.com/"), "unexpected avatar URL");
|
||||
public void testAvatars() throws Exception {
|
||||
BandcampTestUtils.testImages(extractor.getAvatars());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testBannerUrl() throws Exception {
|
||||
assertTrue(extractor.getBannerUrl().contains("://f4.bcbits.com/"), "unexpected banner URL");
|
||||
public void testBanners() throws Exception {
|
||||
BandcampTestUtils.testImages(extractor.getBanners());
|
||||
}
|
||||
|
||||
@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 testServiceId() {
|
||||
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testName() throws Exception {
|
||||
assertEquals("toupie", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testId() throws Exception {
|
||||
assertEquals("2450875064", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUrl() throws Exception {
|
||||
assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
|
||||
|
@ -30,22 +30,22 @@ public class BandcampCommentsExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasComments() throws IOException, ExtractionException {
|
||||
void hasComments() throws IOException, ExtractionException {
|
||||
assertTrue(extractor.getInitialPage().getItems().size() >= 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommentsAllData() throws IOException, ExtractionException {
|
||||
void testGetCommentsAllData() throws IOException, ExtractionException {
|
||||
ListExtractor.InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
|
||||
assertTrue(comments.hasNextPage());
|
||||
|
||||
DefaultTests.defaultTestListOfItems(Bandcamp, comments.getItems(), comments.getErrors());
|
||||
for (CommentsInfoItem c : comments.getItems()) {
|
||||
for (final CommentsInfoItem c : comments.getItems()) {
|
||||
assertFalse(Utils.isBlank(c.getUploaderName()));
|
||||
assertFalse(Utils.isBlank(c.getUploaderAvatarUrl()));
|
||||
BandcampTestUtils.testImages(c.getUploaderAvatars());
|
||||
assertFalse(Utils.isBlank(c.getCommentText().getContent()));
|
||||
assertFalse(Utils.isBlank(c.getName()));
|
||||
assertFalse(Utils.isBlank(c.getThumbnailUrl()));
|
||||
BandcampTestUtils.testImages(c.getThumbnails());
|
||||
assertFalse(Utils.isBlank(c.getUrl()));
|
||||
assertEquals(-1, c.getLikeCount());
|
||||
assertTrue(Utils.isBlank(c.getTextualLikeCount()));
|
||||
|
@ -19,8 +19,17 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContains;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContainsOnlyEquivalentImages;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertNotOnlyContainsEquivalentImages;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
|
||||
/**
|
||||
@ -37,7 +46,7 @@ public class BandcampPlaylistExtractorTest {
|
||||
* Test whether playlists contain the correct amount of items
|
||||
*/
|
||||
@Test
|
||||
public void testCount() throws ExtractionException, IOException {
|
||||
void testCount() throws ExtractionException, IOException {
|
||||
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age");
|
||||
extractor.fetchPage();
|
||||
|
||||
@ -48,13 +57,13 @@ public class BandcampPlaylistExtractorTest {
|
||||
* Tests whether different stream thumbnails (track covers) get loaded correctly
|
||||
*/
|
||||
@Test
|
||||
public void testDifferentTrackCovers() throws ExtractionException, IOException {
|
||||
void testDifferentTrackCovers() throws ExtractionException, IOException {
|
||||
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://zachbensonarchive.bandcamp.com/album/results-of-boredom");
|
||||
extractor.fetchPage();
|
||||
|
||||
final List<StreamInfoItem> l = extractor.getInitialPage().getItems();
|
||||
assertEquals(extractor.getThumbnailUrl(), l.get(0).getThumbnailUrl());
|
||||
assertNotEquals(extractor.getThumbnailUrl(), l.get(5).getThumbnailUrl());
|
||||
assertContainsOnlyEquivalentImages(extractor.getThumbnails(), l.get(0).getThumbnails());
|
||||
assertNotOnlyContainsEquivalentImages(extractor.getThumbnails(), l.get(5).getThumbnails());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,23 +71,23 @@ public class BandcampPlaylistExtractorTest {
|
||||
*/
|
||||
@Test
|
||||
@Timeout(10)
|
||||
public void testDifferentTrackCoversDuration() throws ExtractionException, IOException {
|
||||
void testDifferentTrackCoversDuration() throws ExtractionException, IOException {
|
||||
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://infiniteammo.bandcamp.com/album/night-in-the-woods-vol-1-at-the-end-of-everything");
|
||||
extractor.fetchPage();
|
||||
|
||||
/* All tracks in this album have the same cover art, but I don't know any albums with more than 10 tracks
|
||||
* that has at least one track with a cover art different from the rest.
|
||||
/* All tracks on this album have the same cover art, but I don't know any albums with more
|
||||
* than 10 tracks that has at least one track with a cover art different from the rest.
|
||||
*/
|
||||
final List<StreamInfoItem> l = extractor.getInitialPage().getItems();
|
||||
assertEquals(extractor.getThumbnailUrl(), l.get(0).getThumbnailUrl());
|
||||
assertEquals(extractor.getThumbnailUrl(), l.get(5).getThumbnailUrl());
|
||||
assertContainsOnlyEquivalentImages(extractor.getThumbnails(), l.get(0).getThumbnails());
|
||||
assertContainsOnlyEquivalentImages(extractor.getThumbnails(), l.get(5).getThumbnails());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test playlists with locked content
|
||||
*/
|
||||
@Test
|
||||
public void testLockedContent() throws ExtractionException, IOException {
|
||||
void testLockedContent() throws ExtractionException {
|
||||
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://billwurtz.bandcamp.com/album/high-enough");
|
||||
|
||||
assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
|
||||
@ -88,12 +97,11 @@ public class BandcampPlaylistExtractorTest {
|
||||
* Test playlist with just one track
|
||||
*/
|
||||
@Test
|
||||
public void testSingleStreamPlaylist() throws ExtractionException, IOException {
|
||||
void testSingleStreamPlaylist() throws ExtractionException, IOException {
|
||||
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://zachjohnson1.bandcamp.com/album/endless");
|
||||
extractor.fetchPage();
|
||||
|
||||
assertEquals(1, extractor.getStreamCount());
|
||||
|
||||
}
|
||||
|
||||
public static class ComingOfAge implements BasePlaylistExtractorTest {
|
||||
@ -108,17 +116,17 @@ public class BandcampPlaylistExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThumbnailUrl() throws ParsingException {
|
||||
assertTrue(extractor.getThumbnailUrl().contains("f4.bcbits.com/img"));
|
||||
public void testThumbnails() throws ParsingException {
|
||||
BandcampTestUtils.testImages(extractor.getThumbnails());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBannerUrl() throws ParsingException {
|
||||
assertEquals("", extractor.getBannerUrl());
|
||||
public void testBanners() throws ParsingException {
|
||||
assertEmpty(extractor.getBanners());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderUrl() throws ParsingException {
|
||||
void testUploaderUrl() throws ParsingException {
|
||||
assertTrue(extractor.getUploaderUrl().contains("macbenson.bandcamp.com"));
|
||||
}
|
||||
|
||||
@ -128,8 +136,8 @@ public class BandcampPlaylistExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderAvatarUrl() throws ParsingException {
|
||||
assertTrue(extractor.getUploaderAvatarUrl().contains("f4.bcbits.com/img"));
|
||||
public void testUploaderAvatars() throws ParsingException {
|
||||
BandcampTestUtils.testImages(extractor.getUploaderAvatars());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -147,13 +155,14 @@ public class BandcampPlaylistExtractorTest {
|
||||
assertContains("all rights reserved", description.getContent()); // license
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUploaderVerified() throws Exception {
|
||||
assertFalse(extractor.isUploaderVerified());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitialPage() throws IOException, ExtractionException {
|
||||
void testInitialPage() throws IOException, ExtractionException {
|
||||
assertNotNull(extractor.getInitialPage().getItems().get(0));
|
||||
}
|
||||
|
||||
@ -183,7 +192,7 @@ public class BandcampPlaylistExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNextPageUrl() throws IOException, ExtractionException {
|
||||
void testNextPageUrl() throws IOException, ExtractionException {
|
||||
assertNull(extractor.getPage(extractor.getInitialPage().getNextPage()));
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,14 @@ 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.ExtractorAsserts;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.DefaultTests;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
@ -36,7 +38,7 @@ public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGettingCorrectStreamExtractor() throws ExtractionException {
|
||||
void testGettingCorrectStreamExtractor() throws ExtractionException {
|
||||
assertTrue(Bandcamp.getStreamExtractor("https://bandcamp.com/?show=3") instanceof BandcampRadioStreamExtractor);
|
||||
assertFalse(Bandcamp.getStreamExtractor("https://zachbenson.bandcamp.com/track/deflated")
|
||||
instanceof BandcampRadioStreamExtractor);
|
||||
@ -57,15 +59,16 @@ public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest
|
||||
@Override public int expectedStreamSegmentsCount() { return 30; }
|
||||
|
||||
@Test
|
||||
public void testGetUploaderUrl() {
|
||||
void testGetUploaderUrl() {
|
||||
assertThrows(ContentNotSupportedException.class, extractor::getUploaderUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUploaderUrl() throws Exception {
|
||||
public void testUploaderUrl() {
|
||||
assertThrows(ContentNotSupportedException.class, super::testUploaderUrl);
|
||||
}
|
||||
|
||||
@Override public String expectedUploaderUrl() { return null; }
|
||||
|
||||
@Override
|
||||
@ -93,16 +96,19 @@ public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertTrue(extractor.getThumbnailUrl().contains("bcbits.com/img"));
|
||||
void testGetThumbnails() throws ParsingException {
|
||||
BandcampTestUtils.testImages(extractor.getThumbnails());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertTrue(extractor.getUploaderAvatarUrl().contains("bandcamp-button"));
|
||||
void testGetUploaderAvatars() throws ParsingException {
|
||||
DefaultTests.defaultTestImageCollection(extractor.getUploaderAvatars());
|
||||
extractor.getUploaderAvatars().forEach(image ->
|
||||
ExtractorAsserts.assertContains("bandcamp-button", image.getUrl()));
|
||||
}
|
||||
|
||||
@Test public void testGetAudioStreams() throws ExtractionException, IOException {
|
||||
@Test
|
||||
void testGetAudioStreams() throws ExtractionException, IOException {
|
||||
assertEquals(1, extractor.getAudioStreams().size());
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
package org.schabi.newpipe.extractor.services.bandcamp;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@ -50,8 +49,7 @@ public class BandcampSearchExtractorTest {
|
||||
// The track by Zach Benson should be the first result, no?
|
||||
assertEquals("Best Friend's Basement", bestFriendsBasement.getName());
|
||||
assertEquals("Zach Benson", bestFriendsBasement.getUploaderName());
|
||||
assertTrue(bestFriendsBasement.getThumbnailUrl().endsWith(".jpg"));
|
||||
assertTrue(bestFriendsBasement.getThumbnailUrl().contains("f4.bcbits.com/img/"));
|
||||
BandcampTestUtils.testImages(bestFriendsBasement.getThumbnails());
|
||||
assertEquals(InfoItem.InfoType.STREAM, bestFriendsBasement.getInfoType());
|
||||
}
|
||||
|
||||
@ -66,10 +64,8 @@ public class BandcampSearchExtractorTest {
|
||||
|
||||
// C418's artist profile should be the first result, no?
|
||||
assertEquals("C418", c418.getName());
|
||||
assertTrue(c418.getThumbnailUrl().endsWith(".jpg"));
|
||||
assertTrue(c418.getThumbnailUrl().contains("f4.bcbits.com/img/"));
|
||||
BandcampTestUtils.testImages(c418.getThumbnails());
|
||||
assertEquals("https://c418.bandcamp.com", c418.getUrl());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,9 +78,9 @@ public class BandcampSearchExtractorTest {
|
||||
|
||||
// Minecraft volume alpha should be the first result, no?
|
||||
assertEquals("Minecraft - Volume Alpha", minecraft.getName());
|
||||
assertTrue(minecraft.getThumbnailUrl().endsWith(".jpg"));
|
||||
assertTrue(minecraft.getThumbnailUrl().contains("f4.bcbits.com/img/"));
|
||||
assertEquals("https://c418.bandcamp.com/album/minecraft-volume-alpha",
|
||||
BandcampTestUtils.testImages(minecraft.getThumbnails());
|
||||
assertEquals(
|
||||
"https://c418.bandcamp.com/album/minecraft-volume-alpha",
|
||||
minecraft.getUrl());
|
||||
|
||||
// Verify that playlist tracks counts get extracted correctly
|
||||
|
@ -20,7 +20,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
||||
|
||||
/**
|
||||
@ -150,13 +149,12 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArtistProfilePicture() throws Exception {
|
||||
final String url = extractor().getUploaderAvatarUrl();
|
||||
assertTrue(url.contains("://f4.bcbits.com/img/") && url.endsWith(".jpg"));
|
||||
void testArtistProfilePictures() {
|
||||
BandcampTestUtils.testImages(extractor.getUploaderAvatars());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateIdsToUrl() throws ParsingException {
|
||||
void testTranslateIdsToUrl() throws ParsingException {
|
||||
// To add tests: look at website's source, search for `band_id` and `item_id`
|
||||
assertEquals(
|
||||
"https://teaganbear.bandcamp.com/track/just-for-the-halibut-creative-commons-attribution",
|
||||
|
Loading…
x
Reference in New Issue
Block a user