NewPipeExtractor/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorT...

210 lines
6.8 KiB
Java
Raw Normal View History

2017-08-08 08:42:28 +02:00
package org.schabi.newpipe.extractor.services.soundcloud;
2021-12-27 21:08:08 +01:00
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
2017-08-08 08:42:28 +02:00
import org.schabi.newpipe.extractor.NewPipe;
2017-08-11 03:23:09 +02:00
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
2018-03-04 21:26:13 +01:00
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelExtractor;
2017-08-08 08:42:28 +02:00
2021-12-27 21:08:08 +01:00
import static org.junit.jupiter.api.Assertions.*;
2018-03-04 21:26:13 +01:00
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
2018-01-04 17:21:03 +01:00
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
2018-03-04 22:22:27 +01:00
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
2017-08-08 08:42:28 +02:00
/**
2018-03-04 21:26:13 +01:00
* Test for {@link SoundcloudChannelExtractor}
2017-08-08 08:42:28 +02:00
*/
2017-08-11 03:23:09 +02:00
public class SoundcloudChannelExtractorTest {
2018-03-04 21:26:13 +01:00
public static class LilUzi implements BaseChannelExtractorTest {
private static SoundcloudChannelExtractor extractor;
2021-12-27 21:08:08 +01:00
@BeforeAll
2018-03-04 21:26:13 +01:00
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
2018-03-04 21:26:13 +01:00
extractor = (SoundcloudChannelExtractor) SoundCloud
.getChannelExtractor("http://soundcloud.com/liluzivert/sets");
extractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
// Extractor
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testServiceId() {
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
}
@Test
public void testName() {
assertEquals("Lil Uzi Vert", extractor.getName());
2018-03-04 21:26:13 +01:00
}
@Test
public void testId() {
assertEquals("10494998", extractor.getId());
}
@Test
public void testUrl() throws ParsingException {
assertEquals("https://soundcloud.com/liluzivert", extractor.getUrl());
2018-03-04 21:26:13 +01:00
}
@Test
public void testOriginalUrl() throws ParsingException {
2018-03-04 21:26:13 +01:00
assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl());
}
/*//////////////////////////////////////////////////////////////////////////
// ListExtractor
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
2018-03-04 21:26:13 +01:00
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
2018-03-04 21:26:13 +01:00
}
/*//////////////////////////////////////////////////////////////////////////
// ChannelExtractor
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testDescription() {
assertNotNull(extractor.getDescription());
}
@Test
public void testAvatarUrl() {
assertIsSecureUrl(extractor.getAvatarUrl());
}
@Test
public void testBannerUrl() {
assertIsSecureUrl(extractor.getBannerUrl());
}
@Test
public void testFeedUrl() {
assertEmpty(extractor.getFeedUrl());
}
@Test
public void testSubscriberCount() {
2021-12-27 21:08:08 +01:00
assertTrue(extractor.getSubscriberCount() >= 1e6, "Wrong subscriber count");
2018-03-04 21:26:13 +01:00
}
@Override
public void testVerified() throws Exception {
assertTrue(extractor.isVerified());
}
2017-08-08 08:42:28 +02:00
}
2018-03-04 21:26:13 +01:00
public static class DubMatix implements BaseChannelExtractorTest {
private static SoundcloudChannelExtractor extractor;
2021-12-27 21:08:08 +01:00
@BeforeAll
2018-03-04 21:26:13 +01:00
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
2018-03-04 21:26:13 +01:00
extractor = (SoundcloudChannelExtractor) SoundCloud
.getChannelExtractor("https://soundcloud.com/dubmatix");
extractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
// Additional Testing
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testGetPageInNewExtractor() throws Exception {
final ChannelExtractor newExtractor = SoundCloud.getChannelExtractor(extractor.getUrl());
defaultTestGetPageInNewExtractor(extractor, newExtractor);
2018-03-04 21:26:13 +01:00
}
/*//////////////////////////////////////////////////////////////////////////
// Extractor
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testServiceId() {
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
}
@Test
public void testName() {
assertEquals("dubmatix", extractor.getName());
}
@Test
public void testId() {
assertEquals("542134", extractor.getId());
}
@Test
public void testUrl() throws ParsingException {
assertEquals("https://soundcloud.com/dubmatix", extractor.getUrl());
2018-03-04 21:26:13 +01:00
}
@Test
public void testOriginalUrl() throws ParsingException {
2018-03-04 21:26:13 +01:00
assertEquals("https://soundcloud.com/dubmatix", extractor.getOriginalUrl());
}
/*//////////////////////////////////////////////////////////////////////////
// ListExtractor
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
2018-03-04 21:26:13 +01:00
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
2018-03-04 21:26:13 +01:00
}
/*//////////////////////////////////////////////////////////////////////////
// ChannelExtractor
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testDescription() {
assertNotNull(extractor.getDescription());
}
@Test
public void testAvatarUrl() {
assertIsSecureUrl(extractor.getAvatarUrl());
}
@Test
public void testBannerUrl() {
assertIsSecureUrl(extractor.getBannerUrl());
}
@Test
public void testFeedUrl() {
assertEmpty(extractor.getFeedUrl());
}
@Test
public void testSubscriberCount() {
2021-12-27 21:08:08 +01:00
assertTrue(extractor.getSubscriberCount() >= 2e6, "Wrong subscriber count");
2018-03-04 21:26:13 +01:00
}
@Override
public void testVerified() throws Exception {
assertTrue(extractor.isVerified());
}
2017-08-08 08:42:28 +02:00
}
}