[PeerTube] Apply changes in extractor tests

Also remove some public test methods modifiers, add missing Test annotations on
old Junit 4 tests (and update them if needed), and improve some code.
This commit is contained in:
AudricV 2022-08-03 16:51:46 +02:00
parent 1d72bac53d
commit ba5315c72d
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
4 changed files with 50 additions and 51 deletions

View File

@ -15,9 +15,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContain;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestImageCollection;
/**
* Test for {@link PeertubeAccountExtractor}
@ -76,13 +77,13 @@ public class PeertubeAccountExtractorTest {
}
@Test
public void testAvatarUrl() throws ParsingException {
assertIsSecureUrl(extractor.getAvatarUrl());
public void testAvatars() {
defaultTestImageCollection(extractor.getAvatars());
}
@Test
public void testBannerUrl() {
assertNull(extractor.getBannerUrl());
public void testBanners() {
assertEmpty(extractor.getBanners());
}
@Test
@ -95,6 +96,7 @@ public class PeertubeAccountExtractorTest {
ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
}
@Test
@Override
public void testVerified() throws Exception {
assertFalse(extractor.isVerified());
@ -160,18 +162,18 @@ public class PeertubeAccountExtractorTest {
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testDescription() throws ParsingException {
public void testDescription() {
assertNotNull(extractor.getDescription());
}
@Test
public void testAvatarUrl() throws ParsingException {
assertIsSecureUrl(extractor.getAvatarUrl());
public void testAvatars() {
defaultTestImageCollection(extractor.getAvatars());
}
@Test
public void testBannerUrl() throws ParsingException {
assertNull(extractor.getBannerUrl());
public void testBanners() {
assertEmpty(extractor.getBanners());
}
@Test
@ -184,6 +186,7 @@ public class PeertubeAccountExtractorTest {
ExtractorAsserts.assertGreaterOrEqual(100, extractor.getSubscriberCount());
}
@Test
@Override
public void testVerified() throws Exception {
assertFalse(extractor.isVerified());

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.services.peertube;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@ -13,11 +12,12 @@ import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannel
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertGreaterOrEqual;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContain;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestImageCollection;
/**
* Test for {@link PeertubeChannelExtractor}
@ -71,33 +71,33 @@ public class PeertubeChannelExtractorTest {
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testDescription() throws ParsingException {
public void testDescription() {
assertNotNull(extractor.getDescription());
}
@Test
public void testParentChannelName() throws ParsingException {
void testParentChannelName() throws ParsingException {
assertEquals("lqdn", extractor.getParentChannelName());
}
@Test
public void testParentChannelUrl() throws ParsingException {
void testParentChannelUrl() throws ParsingException {
assertEquals("https://video.lqdn.fr/accounts/lqdn", extractor.getParentChannelUrl());
}
@Test
public void testParentChannelAvatarUrl() throws ParsingException {
assertIsSecureUrl(extractor.getParentChannelAvatarUrl());
void testParentChannelAvatarUrl() {
defaultTestImageCollection(extractor.getParentChannelAvatars());
}
@Test
public void testAvatarUrl() throws ParsingException {
assertIsSecureUrl(extractor.getAvatarUrl());
public void testAvatars() {
defaultTestImageCollection(extractor.getAvatars());
}
@Test
public void testBannerUrl() throws ParsingException {
assertNull(extractor.getBannerUrl());
public void testBanners() {
assertEmpty(extractor.getBanners());
}
@Test
@ -106,10 +106,11 @@ public class PeertubeChannelExtractorTest {
}
@Test
public void testSubscriberCount() throws ParsingException {
ExtractorAsserts.assertGreaterOrEqual(230, extractor.getSubscriberCount());
public void testSubscriberCount() {
assertGreaterOrEqual(230, extractor.getSubscriberCount());
}
@Test
@Override
public void testVerified() throws Exception {
assertFalse(extractor.isVerified());
@ -176,33 +177,33 @@ public class PeertubeChannelExtractorTest {
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testDescription() throws ParsingException {
public void testDescription() {
assertNotNull(extractor.getDescription());
}
@Test
public void testParentChannelName() throws ParsingException {
void testParentChannelName() throws ParsingException {
assertEquals("nathan", extractor.getParentChannelName());
}
@Test
public void testParentChannelUrl() throws ParsingException {
void testParentChannelUrl() throws ParsingException {
assertEquals("https://skeptikon.fr/accounts/nathan", extractor.getParentChannelUrl());
}
@Test
public void testParentChannelAvatarUrl() throws ParsingException {
assertIsSecureUrl(extractor.getParentChannelAvatarUrl());
void testParentChannelAvatars() {
defaultTestImageCollection(extractor.getParentChannelAvatars());
}
@Test
public void testAvatarUrl() throws ParsingException {
assertIsSecureUrl(extractor.getAvatarUrl());
public void testAvatars() {
defaultTestImageCollection(extractor.getAvatars());
}
@Test
public void testBannerUrl() throws ParsingException {
assertNull(extractor.getBannerUrl());
public void testBanners() throws ParsingException {
assertEmpty(extractor.getBanners());
}
@Test
@ -211,10 +212,11 @@ public class PeertubeChannelExtractorTest {
}
@Test
public void testSubscriberCount() throws ParsingException {
ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
public void testSubscriberCount() {
assertGreaterOrEqual(700, extractor.getSubscriberCount());
}
@Test
@Override
public void testVerified() throws Exception {
assertFalse(extractor.isVerified());

View File

@ -18,6 +18,7 @@ import java.util.Optional;
import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestImageCollection;
public class PeertubeCommentsExtractorTest {
public static class Default {
@ -73,12 +74,12 @@ public class PeertubeCommentsExtractorTest {
.forEach(commentsInfoItem -> {
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderUrl()));
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderName()));
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderAvatarUrl()));
defaultTestImageCollection(commentsInfoItem.getUploaderAvatars());
assertFalse(Utils.isBlank(commentsInfoItem.getCommentId()));
assertFalse(Utils.isBlank(commentsInfoItem.getCommentText().getContent()));
assertFalse(Utils.isBlank(commentsInfoItem.getName()));
assertFalse(Utils.isBlank(commentsInfoItem.getTextualUploadDate()));
assertFalse(Utils.isBlank(commentsInfoItem.getThumbnailUrl()));
defaultTestImageCollection(commentsInfoItem.getThumbnails());
assertFalse(Utils.isBlank(commentsInfoItem.getUrl()));
assertEquals(-1, commentsInfoItem.getLikeCount());
assertTrue(Utils.isBlank(commentsInfoItem.getTextualLikeCount()));

View File

@ -2,9 +2,9 @@ package org.schabi.newpipe.extractor.services.peertube;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestImageCollection;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
@ -31,11 +31,8 @@ public class PeertubePlaylistExtractorTest {
}
@Test
@Disabled("URL changes with every request")
void testGetThumbnailUrl() throws ParsingException {
assertEquals(
"https://framatube.org/static/thumbnails/playlist-96b0ee2b-a5a7-4794-8769-58d8ccb79ab7.jpg",
extractor.getThumbnailUrl());
void testGetThumbnails() throws ParsingException {
defaultTestImageCollection(extractor.getThumbnails());
}
@Test
@ -44,10 +41,8 @@ public class PeertubePlaylistExtractorTest {
}
@Test
void testGetUploaderAvatarUrl() throws ParsingException {
assertEquals(
"https://framatube.org/lazy-static/avatars/c6801ff9-cb49-42e6-b2db-3db623248115.jpg",
extractor.getUploaderAvatarUrl());
void testGetUploaderAvatars() throws ParsingException {
defaultTestImageCollection(extractor.getUploaderAvatars());
}
@Test
@ -76,10 +71,8 @@ public class PeertubePlaylistExtractorTest {
}
@Test
void testGetSubChannelAvatarUrl() throws ParsingException {
assertEquals(
"https://framatube.org/lazy-static/avatars/e801ccce-8694-4309-b0ab-e6f0e552ef77.png",
extractor.getSubChannelAvatarUrl());
void testGetSubChannelAvatars() throws ParsingException {
defaultTestImageCollection(extractor.getSubChannelAvatars());
}
}
}