From ba5315c72dcdfc54839cbecd321310bb8d005117 Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Wed, 3 Aug 2022 16:51:46 +0200 Subject: [PATCH] [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. --- .../PeertubeAccountExtractorTest.java | 23 ++++---- .../PeertubeChannelExtractorTest.java | 52 ++++++++++--------- .../PeertubeCommentsExtractorTest.java | 5 +- .../PeertubePlaylistExtractorTest.java | 21 +++----- 4 files changed, 50 insertions(+), 51 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java index 63397c6ba..869ba31ff 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java @@ -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()); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java index 72ce04839..5b48849f8 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java @@ -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()); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java index 353e00482..ee2303706 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java @@ -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())); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistExtractorTest.java index 37853305a..4c64314cd 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistExtractorTest.java @@ -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()); } } }