Change tests

This commit is contained in:
Fynn Godau 2020-11-27 16:48:06 +01:00
parent c91e21b37c
commit be562b8436
2 changed files with 25 additions and 24 deletions

View File

@ -22,31 +22,29 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
@BeforeClass @BeforeClass
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getChannelExtractor("https://npet.bandcamp.com/releases"); extractor = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases");
extractor.fetchPage(); extractor.fetchPage();
} }
@Test @Test
public void testLength() throws ExtractionException, IOException { public void testLength() throws ExtractionException, IOException {
assertTrue(extractor.getInitialPage().getItems().size() >= 1); assertTrue(extractor.getInitialPage().getItems().size() >= 0);
} }
@Override @Override
@Test @Test
public void testDescription() throws Exception { public void testDescription() throws Exception {
assertEquals("This string will be tested for in NewPipeExtractor tests.", extractor.getDescription()); assertEquals("making music:)", extractor.getDescription());
} }
@Override @Override
public void testAvatarUrl() throws Exception { public void testAvatarUrl() throws Exception {
// Has no avatar assertTrue("unexpected avatar URL", extractor.getAvatarUrl().contains("://f4.bcbits.com/"));
assertEquals("", extractor.getAvatarUrl());
} }
@Override @Override
public void testBannerUrl() throws Exception { public void testBannerUrl() throws Exception {
// Has no banner assertTrue("unexpected banner URL", extractor.getBannerUrl().contains("://f4.bcbits.com/"));
assertEquals("", extractor.getBannerUrl());
} }
@Override @Override
@ -76,21 +74,21 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
@Override @Override
public void testName() throws Exception { public void testName() throws Exception {
assertEquals("NewPipeExtractorTest", extractor.getName()); assertEquals("toupie", extractor.getName());
} }
@Override @Override
public void testId() throws Exception { public void testId() throws Exception {
assertEquals("https://npet.bandcamp.com/", extractor.getId()); assertEquals("https://toupie.bandcamp.com/", extractor.getId());
} }
@Override @Override
public void testUrl() throws Exception { public void testUrl() throws Exception {
assertEquals("https://npet.bandcamp.com/releases", extractor.getUrl()); assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
} }
@Override @Override
public void testOriginalUrl() throws Exception { public void testOriginalUrl() throws Exception {
assertEquals("https://npet.bandcamp.com/releases", extractor.getUrl()); assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
} }
} }

View File

@ -35,10 +35,9 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
@BeforeClass @BeforeClass
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// This test track was uploaded specifically for NewPipeExtractor tests
extractor = (BandcampStreamExtractor) Bandcamp 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(); extractor.fetchPage();
} }
@ -54,22 +53,22 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
@Override @Override
public String expectedName() { public String expectedName() {
return "Track #1"; return "Just for the Halibut [Creative Commons: Attribution]";
} }
@Override @Override
public String expectedId() { 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 @Override
public String expectedUrlContains() { 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 @Override
public String expectedOriginalUrlContains() { 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 @Override
@ -79,17 +78,17 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
@Override @Override
public String expectedUploaderName() { public String expectedUploaderName() {
return "NewPipeExtractorTest"; return "Teaganbear";
} }
@Override @Override
public String expectedUploaderUrl() { public String expectedUploaderUrl() {
return "https://npet.bandcamp.com/"; return "https://teaganbear.bandcamp.com/";
} }
@Override @Override
public List<String> expectedDescriptionContains() { public List<String> 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 @Override
@ -104,12 +103,12 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
@Override @Override
public String expectedUploadDate() { public String expectedUploadDate() {
return "2020-03-17 18:37:44.000"; return "2019-03-10 23:00:42.000";
} }
@Override @Override
public String expectedTextualUploadDate() { public String expectedTextualUploadDate() {
return "17 Mar 2020 18:37:44 GMT"; return "10 Mar 2019 23:00:42 GMT";
} }
@Override @Override
@ -149,7 +148,7 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
@Override @Override
public String expectedCategory() { public String expectedCategory() {
return "acoustic"; return "dance";
} }
@Test @Test
@ -160,7 +159,11 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
@Test @Test
public void testTranslateIdsToUrl() throws ParsingException { 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")
);
} }
} }