Fix failing tests.

This commit is contained in:
Isira Seneviratne 2022-11-04 07:20:01 +05:30
parent ff5f223d3f
commit 416089146e
2 changed files with 24 additions and 22 deletions

View File

@ -2,10 +2,18 @@
package org.schabi.newpipe.extractor.services.bandcamp; 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; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor;
@ -13,12 +21,9 @@ import org.schabi.newpipe.extractor.services.DefaultSearchExtractorTest;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSearchExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSearchExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals; import javax.annotation.Nullable;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
/** /**
* Test for {@link BandcampSearchExtractor} * Test for {@link BandcampSearchExtractor}
@ -73,20 +78,17 @@ public class BandcampSearchExtractorTest {
@Test @Test
void testAlbumSearch() throws ExtractionException, IOException { void testAlbumSearch() throws ExtractionException, IOException {
final SearchExtractor extractor = Bandcamp.getSearchExtractor("minecraft volume alpha"); final SearchExtractor extractor = Bandcamp.getSearchExtractor("minecraft volume alpha");
InfoItem minecraft = extractor.getInitialPage() final InfoItem minecraft = extractor.getInitialPage().getItems().get(0);
.getItems().get(0);
// Minecraft volume alpha should be the first result, no? // Minecraft volume alpha should be the first result, no?
assertEquals("Minecraft: Volume Alpha (cover)", minecraft.getName()); assertEquals("Minecraft - Volume Alpha", minecraft.getName());
assertTrue(minecraft.getThumbnailUrl().endsWith(".jpg")); assertTrue(minecraft.getThumbnailUrl().endsWith(".jpg"));
assertTrue(minecraft.getThumbnailUrl().contains("f4.bcbits.com/img/")); assertTrue(minecraft.getThumbnailUrl().contains("f4.bcbits.com/img/"));
assertEquals( assertEquals("https://c418.bandcamp.com/album/minecraft-volume-alpha",
"https://chromacat248.bandcamp.com/album/minecraft-volume-alpha-cover",
minecraft.getUrl()); minecraft.getUrl());
// Verify that playlist tracks counts get extracted correctly // Verify that playlist tracks counts get extracted correctly
assertEquals(3, ((PlaylistInfoItem) minecraft).getStreamCount()); assertEquals(24, ((PlaylistInfoItem) minecraft).getStreamCount());
} }
/** /**

View File

@ -1,5 +1,8 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -9,9 +12,6 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubePlaylistExtractor; import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubePlaylistExtractor;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
public class PeertubePlaylistExtractorTest { public class PeertubePlaylistExtractorTest {
public static class Shocking { public static class Shocking {
@ -39,41 +39,41 @@ public class PeertubePlaylistExtractorTest {
} }
@Test @Test
void testGetUploaderUrl() throws ParsingException { void testGetUploaderUrl() {
assertEquals("https://skeptikon.fr/accounts/metadechoc", extractor.getUploaderUrl()); assertEquals("https://skeptikon.fr/accounts/metadechoc", extractor.getUploaderUrl());
} }
@Test @Test
void testGetUploaderAvatarUrl() throws ParsingException { void testGetUploaderAvatarUrl() throws ParsingException {
assertEquals( assertEquals(
"https://framatube.org/lazy-static/avatars/cd0f781d-0287-4be2-94f1-24cd732337b2.jpg", "https://framatube.org/lazy-static/avatars/c6801ff9-cb49-42e6-b2db-3db623248115.jpg",
extractor.getUploaderAvatarUrl()); extractor.getUploaderAvatarUrl());
} }
@Test @Test
void testGetUploaderName() throws ParsingException { void testGetUploaderName() {
assertEquals("Méta de Choc", extractor.getUploaderName()); assertEquals("Méta de Choc", extractor.getUploaderName());
} }
@Test @Test
void testGetStreamCount() throws ParsingException { void testGetStreamCount() {
ExtractorAsserts.assertGreaterOrEqual(39, extractor.getStreamCount()); ExtractorAsserts.assertGreaterOrEqual(39, extractor.getStreamCount());
} }
@Test @Test
void testGetSubChannelUrl() throws ParsingException { void testGetSubChannelUrl() {
assertEquals("https://skeptikon.fr/video-channels/metadechoc_channel", extractor.getSubChannelUrl()); assertEquals("https://skeptikon.fr/video-channels/metadechoc_channel", extractor.getSubChannelUrl());
} }
@Test @Test
void testGetSubChannelName() throws ParsingException { void testGetSubChannelName() {
assertEquals("SHOCKING !", extractor.getSubChannelName()); assertEquals("SHOCKING !", extractor.getSubChannelName());
} }
@Test @Test
void testGetSubChannelAvatarUrl() throws ParsingException { void testGetSubChannelAvatarUrl() throws ParsingException {
assertEquals( assertEquals(
"https://framatube.org/lazy-static/avatars/637753af-fcf2-4b61-88f9-b9857c953457.png", "https://framatube.org/lazy-static/avatars/e801ccce-8694-4309-b0ab-e6f0e552ef77.png",
extractor.getSubChannelAvatarUrl()); extractor.getSubChannelAvatarUrl());
} }
} }