[MediaCCC] Add tests for stream and conference link handlers

This commit is contained in:
Stypox 2020-04-11 16:57:56 +02:00
parent 07a90d116a
commit af5b8b1915
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,42 @@
package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
import static org.junit.Assert.assertEquals;
public class MediaCCCConferenceLinkHandlerFactoryTest {
private static MediaCCCConferenceLinkHandlerFactory linkHandler;
@BeforeClass
public static void setUp() {
linkHandler = new MediaCCCConferenceLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance());
}
@Test
public void getId() throws ParsingException {
assertEquals("jh20",
linkHandler.fromUrl("https://media.ccc.de/c/jh20#278").getId());
assertEquals("jh20",
linkHandler.fromUrl("https://media.ccc.de/b/jh20?a=b").getId());
assertEquals("jh20",
linkHandler.fromUrl("https://api.media.ccc.de/public/conferences/jh20&a=b&b=c").getId());
}
@Test
public void getUrl() throws ParsingException {
assertEquals("https://media.ccc.de/c/jh20",
linkHandler.fromUrl("https://media.ccc.de/c/jh20#278").getUrl());
assertEquals("https://media.ccc.de/c/jh20",
linkHandler.fromUrl("https://media.ccc.de/b/jh20?a=b").getUrl());
assertEquals("https://media.ccc.de/c/jh20",
linkHandler.fromUrl("https://api.media.ccc.de/public/conferences/jh20&a=b&b=c").getUrl());
assertEquals("https://media.ccc.de/c/jh20",
linkHandler.fromId("jh20").getUrl());
}
}

View File

@ -0,0 +1,42 @@
package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
import static org.junit.Assert.assertEquals;
public class MediaCCCStreamLinkHandlerFactoryTest {
private static MediaCCCStreamLinkHandlerFactory linkHandler;
@BeforeClass
public static void setUp() {
linkHandler = new MediaCCCStreamLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance());
}
@Test
public void getId() throws ParsingException {
assertEquals("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
linkHandler.fromUrl("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020").getId());
assertEquals("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
linkHandler.fromUrl("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020?a=b").getId());
assertEquals("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
linkHandler.fromUrl("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020#3").getId());
assertEquals("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
linkHandler.fromUrl("https://api.media.ccc.de/public/events/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020&a=b").getId());
}
@Test
public void getUrl() throws ParsingException {
assertEquals("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
linkHandler.fromUrl("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020").getUrl());
assertEquals("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
linkHandler.fromUrl("https://api.media.ccc.de/public/events/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020?b=a&a=b").getUrl());
assertEquals("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
linkHandler.fromId("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020").getUrl());
}
}