Merge pull request #511 from B0pol/errors

Fix PeerTube tests by changing instance
This commit is contained in:
Tobias Groza 2021-01-14 19:15:22 +01:00 committed by GitHub
commit c2ff6723d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 50 deletions

View File

@ -19,16 +19,17 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.*;
* Test for {@link PeertubeAccountExtractor} * Test for {@link PeertubeAccountExtractor}
*/ */
public class PeertubeAccountExtractorTest { public class PeertubeAccountExtractorTest {
public static class KDE implements BaseChannelExtractorTest {
public static class Framasoft implements BaseChannelExtractorTest {
private static PeertubeAccountExtractor extractor; private static PeertubeAccountExtractor extractor;
@BeforeClass @BeforeClass
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
extractor = (PeertubeAccountExtractor) PeerTube extractor = (PeertubeAccountExtractor) PeerTube
.getChannelExtractor("https://peertube.mastodon.host/accounts/kde"); .getChannelExtractor("https://framatube.org/accounts/framasoft");
extractor.fetchPage(); extractor.fetchPage();
} }
@ -43,22 +44,22 @@ public class PeertubeAccountExtractorTest {
@Test @Test
public void testName() throws ParsingException { public void testName() throws ParsingException {
assertEquals("The KDE Community", extractor.getName()); assertEquals("Framasoft", extractor.getName());
} }
@Test @Test
public void testId() throws ParsingException { public void testId() throws ParsingException {
assertEquals("accounts/kde", extractor.getId()); assertEquals("accounts/framasoft", extractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/accounts/kde", extractor.getUrl()); assertEquals("https://framatube.org/accounts/framasoft", extractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/accounts/kde", extractor.getOriginalUrl()); assertEquals("https://framatube.org/accounts/framasoft", extractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -96,25 +97,25 @@ public class PeertubeAccountExtractorTest {
@Test @Test
public void testFeedUrl() throws ParsingException { public void testFeedUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?accountId=32465", extractor.getFeedUrl()); assertEquals("https://framatube.org/feeds/videos.xml?accountId=3", extractor.getFeedUrl());
} }
@Test @Test
public void testSubscriberCount() throws ParsingException { public void testSubscriberCount() throws ParsingException {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 5); assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 500);
} }
} }
public static class Booteille implements BaseChannelExtractorTest { public static class FreeSoftwareFoundation implements BaseChannelExtractorTest {
private static PeertubeAccountExtractor extractor; private static PeertubeAccountExtractor extractor;
@BeforeClass @BeforeClass
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
extractor = (PeertubeAccountExtractor) PeerTube extractor = (PeertubeAccountExtractor) PeerTube
.getChannelExtractor("https://peertube.mastodon.host/api/v1/accounts/booteille"); .getChannelExtractor("https://framatube.org/api/v1/accounts/fsf");
extractor.fetchPage(); extractor.fetchPage();
} }
@ -139,22 +140,22 @@ public class PeertubeAccountExtractorTest {
@Test @Test
public void testName() throws ParsingException { public void testName() throws ParsingException {
assertEquals("booteille", extractor.getName()); assertEquals("Free Software Foundation", extractor.getName());
} }
@Test @Test
public void testId() throws ParsingException { public void testId() throws ParsingException {
assertEquals("accounts/booteille", extractor.getId()); assertEquals("accounts/fsf", extractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getUrl()); assertEquals("https://framatube.org/accounts/fsf", extractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/api/v1/accounts/booteille", extractor.getOriginalUrl()); assertEquals("https://framatube.org/api/v1/accounts/fsf", extractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -185,20 +186,19 @@ public class PeertubeAccountExtractorTest {
assertIsSecureUrl(extractor.getAvatarUrl()); assertIsSecureUrl(extractor.getAvatarUrl());
} }
@Ignore
@Test @Test
public void testBannerUrl() throws ParsingException { public void testBannerUrl() throws ParsingException {
assertIsSecureUrl(extractor.getBannerUrl()); assertNull(extractor.getBannerUrl());
} }
@Test @Test
public void testFeedUrl() throws ParsingException { public void testFeedUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?accountId=1753", extractor.getFeedUrl()); assertEquals("https://framatube.org/feeds/videos.xml?accountId=8178", extractor.getFeedUrl());
} }
@Test @Test
public void testSubscriberCount() throws ParsingException { public void testSubscriberCount() throws ParsingException {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 1); assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 100);
} }
} }
} }

View File

@ -19,16 +19,17 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.*;
* Test for {@link PeertubeChannelExtractor} * Test for {@link PeertubeChannelExtractor}
*/ */
public class PeertubeChannelExtractorTest { public class PeertubeChannelExtractorTest {
public static class DanDAugeTutoriels implements BaseChannelExtractorTest {
public static class LaQuadratureDuNet implements BaseChannelExtractorTest {
private static PeertubeChannelExtractor extractor; private static PeertubeChannelExtractor extractor;
@BeforeClass @BeforeClass
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
extractor = (PeertubeChannelExtractor) PeerTube extractor = (PeertubeChannelExtractor) PeerTube
.getChannelExtractor("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa"); .getChannelExtractor("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos");
extractor.fetchPage(); extractor.fetchPage();
} }
@ -43,22 +44,22 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testName() throws ParsingException { public void testName() throws ParsingException {
assertEquals("Dan d'Auge tutoriels", extractor.getName()); assertEquals("La Quadrature du Net", extractor.getName());
} }
@Test @Test
public void testId() throws ParsingException { public void testId() throws ParsingException {
assertEquals("video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getId()); assertEquals("video-channels/lqdn_channel@video.lqdn.fr", extractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getUrl()); assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr", extractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getOriginalUrl()); assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -86,12 +87,12 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testParentChannelName() throws ParsingException { public void testParentChannelName() throws ParsingException {
assertEquals("libux", extractor.getParentChannelName()); assertEquals("lqdn", extractor.getParentChannelName());
} }
@Test @Test
public void testParentChannelUrl() throws ParsingException { public void testParentChannelUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/accounts/libux", extractor.getParentChannelUrl()); assertEquals("https://video.lqdn.fr/accounts/lqdn", extractor.getParentChannelUrl());
} }
@Test @Test
@ -111,25 +112,26 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testFeedUrl() throws ParsingException { public void testFeedUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?videoChannelId=1361", extractor.getFeedUrl()); assertEquals("https://framatube.org/feeds/videos.xml?videoChannelId=1126", extractor.getFeedUrl());
} }
@Test @Test
public void testSubscriberCount() throws ParsingException { public void testSubscriberCount() throws ParsingException {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 4); assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 230);
} }
} }
public static class Divers implements BaseChannelExtractorTest { public static class ChatSceptique implements BaseChannelExtractorTest {
private static PeertubeChannelExtractor extractor; private static PeertubeChannelExtractor extractor;
@BeforeClass @BeforeClass
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
extractor = (PeertubeChannelExtractor) PeerTube extractor = (PeertubeChannelExtractor) PeerTube
.getChannelExtractor("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457"); .getChannelExtractor("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr");
extractor.fetchPage(); extractor.fetchPage();
} }
@ -154,22 +156,22 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testName() throws ParsingException { public void testName() throws ParsingException {
assertEquals("Divers", extractor.getName()); assertEquals("Chat Sceptique", extractor.getName());
} }
@Test @Test
public void testId() throws ParsingException { public void testId() throws ParsingException {
assertEquals("video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getId()); assertEquals("video-channels/chatsceptique@skeptikon.fr", extractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getUrl()); assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr", extractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getOriginalUrl()); assertEquals("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr", extractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -197,12 +199,12 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testParentChannelName() throws ParsingException { public void testParentChannelName() throws ParsingException {
assertEquals("booteille", extractor.getParentChannelName()); assertEquals("nathan", extractor.getParentChannelName());
} }
@Test @Test
public void testParentChannelUrl() throws ParsingException { public void testParentChannelUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getParentChannelUrl()); assertEquals("https://skeptikon.fr/accounts/nathan", extractor.getParentChannelUrl());
} }
@Test @Test
@ -215,20 +217,19 @@ public class PeertubeChannelExtractorTest {
assertIsSecureUrl(extractor.getAvatarUrl()); assertIsSecureUrl(extractor.getAvatarUrl());
} }
@Ignore
@Test @Test
public void testBannerUrl() throws ParsingException { public void testBannerUrl() throws ParsingException {
assertIsSecureUrl(extractor.getBannerUrl()); assertNull(extractor.getBannerUrl());
} }
@Test @Test
public void testFeedUrl() throws ParsingException { public void testFeedUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?videoChannelId=1227", extractor.getFeedUrl()); assertEquals("https://framatube.org/feeds/videos.xml?videoChannelId=137", extractor.getFeedUrl());
} }
@Test @Test
public void testSubscriberCount() throws ParsingException { public void testSubscriberCount() throws ParsingException {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 2); assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 700);
} }
} }
} }

View File

@ -13,6 +13,7 @@ import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.*; import static org.schabi.newpipe.extractor.services.DefaultTests.*;
public class PeertubeTrendingExtractorTest { public class PeertubeTrendingExtractorTest {
public static class Trending implements BaseListExtractorTest { public static class Trending implements BaseListExtractorTest {
private static PeertubeTrendingExtractor extractor; private static PeertubeTrendingExtractor extractor;
@ -20,7 +21,7 @@ public class PeertubeTrendingExtractorTest {
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
extractor = (PeertubeTrendingExtractor) PeerTube.getKioskList() extractor = (PeertubeTrendingExtractor) PeerTube.getKioskList()
.getExtractorById("Trending", null); .getExtractorById("Trending", null);
extractor.fetchPage(); extractor.fetchPage();
@ -47,12 +48,12 @@ public class PeertubeTrendingExtractorTest {
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/api/v1/videos?sort=-trending", extractor.getUrl()); assertEquals("https://framatube.org/api/v1/videos?sort=-trending", extractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://peertube.mastodon.host/api/v1/videos?sort=-trending", extractor.getOriginalUrl()); assertEquals("https://framatube.org/api/v1/videos?sort=-trending", extractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////

View File

@ -23,13 +23,13 @@ public class PeertubeSearchExtractorTest {
public static class All extends DefaultSearchExtractorTest { public static class All extends DefaultSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "kde"; private static final String QUERY = "fsf";
@BeforeClass @BeforeClass
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
extractor = PeerTube.getSearchExtractor(QUERY); extractor = PeerTube.getSearchExtractor(QUERY);
extractor.fetchPage(); extractor.fetchPage();
} }
@ -52,7 +52,7 @@ public class PeertubeSearchExtractorTest {
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
extractor = PeerTube.getSearchExtractor(QUERY, singletonList(PeertubeSearchQueryHandlerFactory.SEPIA_VIDEOS), ""); extractor = PeerTube.getSearchExtractor(QUERY, singletonList(PeertubeSearchQueryHandlerFactory.SEPIA_VIDEOS), "");
extractor.fetchPage(); extractor.fetchPage();
} }