From be562b84365a9b74ce0708cae53972aade36bfaf Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Fri, 27 Nov 2020 16:48:06 +0100 Subject: [PATCH] Change tests --- .../BandcampChannelExtractorTest.java | 20 ++++++------- .../bandcamp/BandcampStreamExtractorTest.java | 29 ++++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java index a5ccabf9d..327dc6b9a 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java @@ -22,31 +22,29 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(DownloaderTestImpl.getInstance()); - extractor = Bandcamp.getChannelExtractor("https://npet.bandcamp.com/releases"); + extractor = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases"); extractor.fetchPage(); } @Test public void testLength() throws ExtractionException, IOException { - assertTrue(extractor.getInitialPage().getItems().size() >= 1); + assertTrue(extractor.getInitialPage().getItems().size() >= 0); } @Override @Test public void testDescription() throws Exception { - assertEquals("This string will be tested for in NewPipeExtractor tests.", extractor.getDescription()); + assertEquals("making music:)", extractor.getDescription()); } @Override public void testAvatarUrl() throws Exception { - // Has no avatar - assertEquals("", extractor.getAvatarUrl()); + assertTrue("unexpected avatar URL", extractor.getAvatarUrl().contains("://f4.bcbits.com/")); } @Override public void testBannerUrl() throws Exception { - // Has no banner - assertEquals("", extractor.getBannerUrl()); + assertTrue("unexpected banner URL", extractor.getBannerUrl().contains("://f4.bcbits.com/")); } @Override @@ -76,21 +74,21 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest { @Override public void testName() throws Exception { - assertEquals("NewPipeExtractorTest", extractor.getName()); + assertEquals("toupie", extractor.getName()); } @Override public void testId() throws Exception { - assertEquals("https://npet.bandcamp.com/", extractor.getId()); + assertEquals("https://toupie.bandcamp.com/", extractor.getId()); } @Override public void testUrl() throws Exception { - assertEquals("https://npet.bandcamp.com/releases", extractor.getUrl()); + assertEquals("https://toupie.bandcamp.com", extractor.getUrl()); } @Override public void testOriginalUrl() throws Exception { - assertEquals("https://npet.bandcamp.com/releases", extractor.getUrl()); + assertEquals("https://toupie.bandcamp.com", extractor.getUrl()); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java index f61018820..dd979d554 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java @@ -35,10 +35,9 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest { @BeforeClass public static void setUp() throws ExtractionException, IOException { NewPipe.init(DownloaderTestImpl.getInstance()); - // This test track was uploaded specifically for NewPipeExtractor tests extractor = (BandcampStreamExtractor) Bandcamp - .getStreamExtractor("https://npet.bandcamp.com/track/track-1"); + .getStreamExtractor("https://teaganbear.bandcamp.com/track/just-for-the-halibut-creative-commons-attribution"); extractor.fetchPage(); } @@ -54,22 +53,22 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest { @Override public String expectedName() { - return "Track #1"; + return "Just for the Halibut [Creative Commons: Attribution]"; } @Override public String expectedId() { - return "https://npet.bandcamp.com/track/track-1"; + return "https://teaganbear.bandcamp.com/track/just-for-the-halibut-creative-commons-attribution"; } @Override public String expectedUrlContains() { - return "https://npet.bandcamp.com/track/track-1"; + return "https://teaganbear.bandcamp.com/track/just-for-the-halibut-creative-commons-attribution"; } @Override public String expectedOriginalUrlContains() { - return "https://npet.bandcamp.com/track/track-1"; + return "https://teaganbear.bandcamp.com/track/just-for-the-halibut-creative-commons-attribution"; } @Override @@ -79,17 +78,17 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest { @Override public String expectedUploaderName() { - return "NewPipeExtractorTest"; + return "Teaganbear"; } @Override public String expectedUploaderUrl() { - return "https://npet.bandcamp.com/"; + return "https://teaganbear.bandcamp.com/"; } @Override public List expectedDescriptionContains() { - return Collections.singletonList("This sample track was created using MuseScore."); + return Collections.singletonList("it's Creative Commons so feel free to use it in whatever"); } @Override @@ -104,12 +103,12 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest { @Override public String expectedUploadDate() { - return "2020-03-17 18:37:44.000"; + return "2019-03-10 23:00:42.000"; } @Override public String expectedTextualUploadDate() { - return "17 Mar 2020 18:37:44 GMT"; + return "10 Mar 2019 23:00:42 GMT"; } @Override @@ -149,7 +148,7 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest { @Override public String expectedCategory() { - return "acoustic"; + return "dance"; } @Test @@ -160,7 +159,11 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest { @Test public void testTranslateIdsToUrl() throws ParsingException { - assertEquals("https://npet.bandcamp.com/track/track-1", BandcampExtractorHelper.getStreamUrlFromIds(3775652329L, 4207805220L, "track")); + // 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", + BandcampExtractorHelper.getStreamUrlFromIds(3877364987L, 3486455278L, "track") + ); } }