[SoundCloud] Add test for small playlist, use defaultTestGetPageInNewExtractor
This commit is contained in:
parent
45bb646480
commit
265cfb61f3
|
@ -1,6 +1,5 @@
|
||||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||||
|
|
||||||
import org.hamcrest.CoreMatchers;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.schabi.newpipe.DownloaderTestImpl;
|
import org.schabi.newpipe.DownloaderTestImpl;
|
||||||
|
@ -10,6 +9,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
@ -71,14 +71,6 @@ public class SoundcloudPlaylistExtractorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMoreRelatedItems() throws Exception {
|
public void testMoreRelatedItems() throws Exception {
|
||||||
defaultTestMoreItems(extractor);
|
defaultTestMoreItems(extractor);
|
||||||
|
|
||||||
try {
|
|
||||||
defaultTestMoreItems(extractor);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fail("This playlist doesn't have more items, it should throw an error");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -100,7 +92,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||||
public void testUploaderUrl() {
|
public void testUploaderUrl() {
|
||||||
final String uploaderUrl = extractor.getUploaderUrl();
|
final String uploaderUrl = extractor.getUploaderUrl();
|
||||||
assertIsSecureUrl(uploaderUrl);
|
assertIsSecureUrl(uploaderUrl);
|
||||||
assertTrue(uploaderUrl, uploaderUrl.contains("liluzivert"));
|
assertThat(uploaderUrl, containsString("liluzivert"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -115,7 +107,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStreamCount() {
|
public void testStreamCount() {
|
||||||
assertTrue("Error in the streams count", extractor.getStreamCount() >= 10);
|
assertTrue("Stream count does not fit: " + extractor.getStreamCount(), extractor.getStreamCount() >= 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +184,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||||
public void testUploaderUrl() {
|
public void testUploaderUrl() {
|
||||||
final String uploaderUrl = extractor.getUploaderUrl();
|
final String uploaderUrl = extractor.getUploaderUrl();
|
||||||
assertIsSecureUrl(uploaderUrl);
|
assertIsSecureUrl(uploaderUrl);
|
||||||
assertThat(uploaderUrl, CoreMatchers.containsString("micky96"));
|
assertThat(uploaderUrl, containsString("micky96"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -207,7 +199,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStreamCount() {
|
public void testStreamCount() {
|
||||||
assertTrue("Error in the streams count", extractor.getStreamCount() >= 10);
|
assertTrue("Stream count does not fit: " + extractor.getStreamCount(), extractor.getStreamCount() >= 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,17 +220,8 @@ public class SoundcloudPlaylistExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPageInNewExtractor() throws Exception {
|
public void testGetPageInNewExtractor() throws Exception {
|
||||||
final PlaylistExtractor newExtractor = SoundCloud.getPlaylistExtractor(extractor.getUrl());
|
PlaylistExtractor newExtractor = SoundCloud.getPlaylistExtractor(extractor.getUrl());
|
||||||
defaultTestGetPageInNewExtractor(extractor, newExtractor);
|
defaultTestGetPageInNewExtractor(extractor, newExtractor);
|
||||||
String page1 = newExtractor.getNextPageUrl();
|
|
||||||
defaultTestMoreItems(newExtractor); // there has to be another page
|
|
||||||
String page2 = newExtractor.getNextPageUrl();
|
|
||||||
defaultTestMoreItems(newExtractor); // and another one
|
|
||||||
String page3 = newExtractor.getNextPageUrl();
|
|
||||||
|
|
||||||
assertNotEquals("Same pages", page1, page2);
|
|
||||||
assertNotEquals("Same pages", page2, page3);
|
|
||||||
assertNotEquals("Same pages", page3, page1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -326,4 +309,102 @@ public class SoundcloudPlaylistExtractorTest {
|
||||||
assertTrue("Stream count does not fit: " + extractor.getStreamCount(), extractor.getStreamCount() >= 370);
|
assertTrue("Stream count does not fit: " + extractor.getStreamCount(), extractor.getStreamCount() >= 370);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SmallPlaylist implements BasePlaylistExtractorTest {
|
||||||
|
private static SoundcloudPlaylistExtractor extractor;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() throws Exception {
|
||||||
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||||
|
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||||
|
.getPlaylistExtractor("https://soundcloud.com/breezy-123/sets/empty-playlist?test=123");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Extractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServiceId() {
|
||||||
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() {
|
||||||
|
assertEquals("EMPTY PLAYLIST", extractor.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testId() {
|
||||||
|
assertEquals("23483459", extractor.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUrl() throws Exception {
|
||||||
|
assertEquals("https://soundcloud.com/breezy-123/sets/empty-playlist", extractor.getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOriginalUrl() throws Exception {
|
||||||
|
assertEquals("https://soundcloud.com/breezy-123/sets/empty-playlist?test=123", extractor.getOriginalUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
defaultTestRelatedItems(extractor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
try {
|
||||||
|
defaultTestMoreItems(extractor);
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fail("This playlist doesn't have more items, it should throw an error");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlaylistExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testThumbnailUrl() {
|
||||||
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBannerUrl() {
|
||||||
|
// SoundCloud playlists do not have a banner
|
||||||
|
assertNull(extractor.getBannerUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploaderUrl() {
|
||||||
|
final String uploaderUrl = extractor.getUploaderUrl();
|
||||||
|
assertIsSecureUrl(uploaderUrl);
|
||||||
|
assertThat(uploaderUrl, containsString("breezy-123"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploaderName() {
|
||||||
|
assertEquals("breezy-123", extractor.getUploaderName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploaderAvatarUrl() {
|
||||||
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStreamCount() {
|
||||||
|
assertEquals(2, extractor.getStreamCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue