Improved Bandcamp radio stream extractor tests

This commit is contained in:
Fynn Godau 2020-06-04 12:30:53 +02:00
parent 8f6c00f8d8
commit e98bff8ae9

View file

@ -6,8 +6,10 @@ import org.schabi.newpipe.DownloaderTestImpl;
import org.schabi.newpipe.extractor.Extractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioStreamExtractor;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import java.io.IOException;
@ -16,9 +18,15 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
public class BandcampRadioStreamExtractorTest {
private static StreamExtractor e;
private static final String SHOW_URL = "https://bandcamp.com/?show=230";
@BeforeClass
public static void setUp() {
public static void setUp() throws IOException, ExtractionException {
NewPipe.init(DownloaderTestImpl.getInstance());
e = Bandcamp.getStreamExtractor(SHOW_URL);
e.fetchPage();
}
@Test
@ -28,10 +36,69 @@ public class BandcampRadioStreamExtractorTest {
}
@Test
public void testExtracting() throws ExtractionException, IOException {
BandcampRadioStreamExtractor e = (BandcampRadioStreamExtractor) Bandcamp.getStreamExtractor("https://bandcamp.com/?show=230");
e.fetchPage();
public void testGetName() throws ParsingException {
assertEquals("Sound Movements", e.getName());
}
@Test
public void testGetUploaderUrl() {
}
@Test
public void testGetUrl() throws ParsingException {
assertEquals(SHOW_URL, e.getUrl());
}
@Test
public void testGetUploaderName() throws ParsingException {
assertEquals("Andrew Jervis", e.getUploaderName());
}
@Test
public void testGetTextualUploadDate() throws ParsingException {
assertEquals("16 May 2017", e.getTextualUploadDate());
}
@Test
public void testGetThumbnailUrl() throws ParsingException {
assertTrue(e.getThumbnailUrl().contains("bcbits.com/img"));
}
@Test
public void testGetUploaderAvatarUrl() throws ParsingException {
assertTrue(e.getUploaderAvatarUrl().contains("bandcamp-button"));
}
@Test
public void testGetDescription() throws ParsingException {
assertEquals("Featuring special guests Nick Hakim and Elbows, plus fresh cuts from Eddie Palmieri, KRS One, Ladi6, and Moonchild.", e.getDescription().getContent());
}
@Test
public void testGetLength() throws ParsingException {
assertEquals(5619, e.getLength());
}
@Test
public void testGetAudioStreams() throws ExtractionException, IOException {
assertEquals(2, e.getAudioStreams().size());
}
@Test
public void testGetLicence() throws ParsingException {
assertEquals("", e.getLicence());
}
@Test
public void testGetCategory() throws ParsingException {
assertEquals("", e.getCategory());
}
@Test
public void testGetTags() throws ParsingException {
assertEquals(0, e.getTags().size());
}
}