Merge pull request #234 from TeamNewPipe/fix/YT_search_test
Fix and improve tests
This commit is contained in:
commit
82eff772fa
|
@ -43,6 +43,7 @@ public abstract class LinkHandlerFactory {
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
public LinkHandler fromUrl(String url) throws ParsingException {
|
public LinkHandler fromUrl(String url) throws ParsingException {
|
||||||
|
if (url == null) throw new IllegalArgumentException("url can not be null");
|
||||||
final String baseUrl = Utils.getBaseUrl(url);
|
final String baseUrl = Utils.getBaseUrl(url);
|
||||||
return fromUrl(url, baseUrl);
|
return fromUrl(url, baseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class MediaCCCStreamExtractorTest implements BaseExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTextualUploadDate() throws ParsingException {
|
public void testGetTextualUploadDate() throws ParsingException {
|
||||||
Assert.assertEquals("2018-05-11", extractor.getTextualUploadDate());
|
Assert.assertEquals("2018-05-11T02:00:00.000+02:00", extractor.getTextualUploadDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -77,8 +77,8 @@ public class YoutubeStreamLinkHandlerFactoryTest {
|
||||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.Youtube.com/embed/jZViOEv90dI").getId());
|
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.Youtube.com/embed/jZViOEv90dI").getId());
|
||||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI").getId());
|
assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI").getId());
|
||||||
assertEquals("EhxJLojIE_o", linkHandler.fromUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare").getId());
|
assertEquals("EhxJLojIE_o", linkHandler.fromUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare").getId());
|
||||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI").getId());
|
assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI", "youtube.com").getId());
|
||||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube:jZViOEv90dI").getId());
|
assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube:jZViOEv90dI", "youtube.com").getId());
|
||||||
assertEquals("O0EDx9WAelc", linkHandler.fromUrl("https://music.youtube.com/watch?v=O0EDx9WAelc").getId());
|
assertEquals("O0EDx9WAelc", linkHandler.fromUrl("https://music.youtube.com/watch?v=O0EDx9WAelc").getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
package org.schabi.newpipe.extractor.services.youtube.search;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.schabi.newpipe.DownloaderTestImpl;
|
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
|
|
||||||
|
|
||||||
import static java.util.Collections.singletonList;
|
|
||||||
import static junit.framework.TestCase.assertTrue;
|
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for {@link YoutubeSearchExtractor}
|
|
||||||
*/
|
|
||||||
public class YoutubeSearchCountTest {
|
|
||||||
public static class YoutubeChannelViewCountTest extends YoutubeSearchExtractorBaseTest {
|
|
||||||
@BeforeClass
|
|
||||||
public static void setUpClass() throws Exception {
|
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
|
||||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
|
||||||
singletonList(YoutubeSearchQueryHandlerFactory.CHANNELS), null);
|
|
||||||
extractor.fetchPage();
|
|
||||||
itemsPage = extractor.getInitialPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testViewCount() {
|
|
||||||
ChannelInfoItem ci = (ChannelInfoItem) itemsPage.getItems().get(0);
|
|
||||||
assertTrue("Count does not fit: " + Long.toString(ci.getSubscriberCount()),
|
|
||||||
69043316 < ci.getSubscriberCount() && ci.getSubscriberCount() < 103043316);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -78,4 +78,11 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStreamCount() {
|
||||||
|
ChannelInfoItem ci = (ChannelInfoItem) itemsPage.getItems().get(0);
|
||||||
|
assertTrue("Stream count does not fit: " + ci.getStreamCount(),
|
||||||
|
4000 < ci.getStreamCount() && ci.getStreamCount() < 5500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,13 +122,13 @@ public class YoutubeStreamExtractorControversialTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
// Video (/view?v=T4XJQO3qol8) set in the setUp() method has at least auto-generated (English) captions
|
||||||
assertFalse(extractor.getSubtitlesDefault().isEmpty());
|
assertFalse(extractor.getSubtitlesDefault().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
// Video (/view?v=T4XJQO3qol8) set in the setUp() method has at least auto-generated (English) captions
|
||||||
assertFalse(extractor.getSubtitles(MediaFormat.TTML).isEmpty());
|
assertFalse(extractor.getSubtitles(MediaFormat.TTML).isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue