From f71bd29d58be131bb3783607a3395251fdb4cd29 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Mon, 20 Apr 2020 23:52:12 +0200 Subject: [PATCH] Bandcamp playlist extractor: add more tests --- .../BandcampPlaylistExtractorTest.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java index fc2f434cd..8af486a1d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java @@ -8,8 +8,11 @@ import org.schabi.newpipe.DownloaderTestImpl; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampPlaylistExtractor; +import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor; +import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamInfoItemExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import java.io.IOException; @@ -88,4 +91,61 @@ public class BandcampPlaylistExtractorTest { assertEquals(1, extractor.getStreamCount()); } + + public static class ComingOfAge { + + private static PlaylistExtractor extractor; + + @BeforeClass + public static void setUp() throws ExtractionException, IOException { + NewPipe.init(DownloaderTestImpl.getInstance()); + extractor = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age"); + extractor.fetchPage(); + } + + @Test + public void getThumbnailUrl() throws ParsingException { + assertTrue(extractor.getThumbnailUrl().contains("f4.bcbits.com/img")); + } + + @Test + public void getBannerUrl() throws ParsingException { + assertEquals("", extractor.getBannerUrl()); + } + + @Test + public void getUploaderUrl() throws ParsingException { + assertTrue(extractor.getUploaderUrl().contains("macbenson.bandcamp.com")); + } + + @Test + public void getUploaderName() throws ParsingException { + assertEquals("mac benson", extractor.getUploaderName()); + } + + @Test + public void getUploaderAvatarUrl() throws ParsingException { + assertTrue(extractor.getUploaderAvatarUrl().contains("f4.bcbits.com/img")); + } + + @Test + public void getStreamCount() throws ParsingException { + assertEquals(5, extractor.getStreamCount()); + } + + @Test + public void getInitialPage() throws IOException, ExtractionException { + assertNotNull(extractor.getInitialPage().getItems().get(0)); + } + + @Test + public void getName() throws ParsingException { + assertEquals("Coming of Age", extractor.getName()); + } + + @Test + public void getNextPageUrl() throws IOException, ExtractionException { + assertNull(extractor.getNextPageUrl()); + } + } }