Skip to content

Commit ba5315c

Browse files
committed
[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.
1 parent 1d72bac commit ba5315c

4 files changed

Lines changed: 50 additions & 51 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
import static org.junit.jupiter.api.Assertions.assertNotNull;
1616
import static org.junit.jupiter.api.Assertions.assertNull;
1717
import static org.junit.jupiter.api.Assertions.assertTrue;
18-
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
1918
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContain;
19+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
2020
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
21+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestImageCollection;
2122

2223
/**
2324
* Test for {@link PeertubeAccountExtractor}
@@ -76,13 +77,13 @@ public void testDescription() throws ParsingException {
7677
}
7778

7879
@Test
79-
public void testAvatarUrl() throws ParsingException {
80-
assertIsSecureUrl(extractor.getAvatarUrl());
80+
public void testAvatars() {
81+
defaultTestImageCollection(extractor.getAvatars());
8182
}
8283

8384
@Test
84-
public void testBannerUrl() {
85-
assertNull(extractor.getBannerUrl());
85+
public void testBanners() {
86+
assertEmpty(extractor.getBanners());
8687
}
8788

8889
@Test
@@ -95,6 +96,7 @@ public void testSubscriberCount() throws ParsingException {
9596
ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
9697
}
9798

99+
@Test
98100
@Override
99101
public void testVerified() throws Exception {
100102
assertFalse(extractor.isVerified());
@@ -160,18 +162,18 @@ public void testOriginalUrl() throws ParsingException {
160162
//////////////////////////////////////////////////////////////////////////*/
161163

162164
@Test
163-
public void testDescription() throws ParsingException {
165+
public void testDescription() {
164166
assertNotNull(extractor.getDescription());
165167
}
166168

167169
@Test
168-
public void testAvatarUrl() throws ParsingException {
169-
assertIsSecureUrl(extractor.getAvatarUrl());
170+
public void testAvatars() {
171+
defaultTestImageCollection(extractor.getAvatars());
170172
}
171173

172174
@Test
173-
public void testBannerUrl() throws ParsingException {
174-
assertNull(extractor.getBannerUrl());
175+
public void testBanners() {
176+
assertEmpty(extractor.getBanners());
175177
}
176178

177179
@Test
@@ -184,6 +186,7 @@ public void testSubscriberCount() throws ParsingException {
184186
ExtractorAsserts.assertGreaterOrEqual(100, extractor.getSubscriberCount());
185187
}
186188

189+
@Test
187190
@Override
188191
public void testVerified() throws Exception {
189192
assertFalse(extractor.isVerified());

extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.junit.jupiter.api.BeforeAll;
44
import org.junit.jupiter.api.Test;
55
import org.schabi.newpipe.downloader.DownloaderTestImpl;
6-
import org.schabi.newpipe.extractor.ExtractorAsserts;
76
import org.schabi.newpipe.extractor.NewPipe;
87
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
98
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -13,11 +12,12 @@
1312
import static org.junit.jupiter.api.Assertions.assertEquals;
1413
import static org.junit.jupiter.api.Assertions.assertFalse;
1514
import static org.junit.jupiter.api.Assertions.assertNotNull;
16-
import static org.junit.jupiter.api.Assertions.assertNull;
1715
import static org.junit.jupiter.api.Assertions.assertTrue;
18-
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
16+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
17+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertGreaterOrEqual;
1918
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContain;
2019
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
20+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestImageCollection;
2121

2222
/**
2323
* Test for {@link PeertubeChannelExtractor}
@@ -71,33 +71,33 @@ public void testOriginalUrl() throws ParsingException {
7171
//////////////////////////////////////////////////////////////////////////*/
7272

7373
@Test
74-
public void testDescription() throws ParsingException {
74+
public void testDescription() {
7575
assertNotNull(extractor.getDescription());
7676
}
7777

7878
@Test
79-
public void testParentChannelName() throws ParsingException {
79+
void testParentChannelName() throws ParsingException {
8080
assertEquals("lqdn", extractor.getParentChannelName());
8181
}
8282

8383
@Test
84-
public void testParentChannelUrl() throws ParsingException {
84+
void testParentChannelUrl() throws ParsingException {
8585
assertEquals("https://video.lqdn.fr/accounts/lqdn", extractor.getParentChannelUrl());
8686
}
8787

8888
@Test
89-
public void testParentChannelAvatarUrl() throws ParsingException {
90-
assertIsSecureUrl(extractor.getParentChannelAvatarUrl());
89+
void testParentChannelAvatarUrl() {
90+
defaultTestImageCollection(extractor.getParentChannelAvatars());
9191
}
9292

9393
@Test
94-
public void testAvatarUrl() throws ParsingException {
95-
assertIsSecureUrl(extractor.getAvatarUrl());
94+
public void testAvatars() {
95+
defaultTestImageCollection(extractor.getAvatars());
9696
}
9797

9898
@Test
99-
public void testBannerUrl() throws ParsingException {
100-
assertNull(extractor.getBannerUrl());
99+
public void testBanners() {
100+
assertEmpty(extractor.getBanners());
101101
}
102102

103103
@Test
@@ -106,10 +106,11 @@ public void testFeedUrl() throws ParsingException {
106106
}
107107

108108
@Test
109-
public void testSubscriberCount() throws ParsingException {
110-
ExtractorAsserts.assertGreaterOrEqual(230, extractor.getSubscriberCount());
109+
public void testSubscriberCount() {
110+
assertGreaterOrEqual(230, extractor.getSubscriberCount());
111111
}
112112

113+
@Test
113114
@Override
114115
public void testVerified() throws Exception {
115116
assertFalse(extractor.isVerified());
@@ -176,33 +177,33 @@ public void testOriginalUrl() throws ParsingException {
176177
//////////////////////////////////////////////////////////////////////////*/
177178

178179
@Test
179-
public void testDescription() throws ParsingException {
180+
public void testDescription() {
180181
assertNotNull(extractor.getDescription());
181182
}
182183

183184
@Test
184-
public void testParentChannelName() throws ParsingException {
185+
void testParentChannelName() throws ParsingException {
185186
assertEquals("nathan", extractor.getParentChannelName());
186187
}
187188

188189
@Test
189-
public void testParentChannelUrl() throws ParsingException {
190+
void testParentChannelUrl() throws ParsingException {
190191
assertEquals("https://skeptikon.fr/accounts/nathan", extractor.getParentChannelUrl());
191192
}
192193

193194
@Test
194-
public void testParentChannelAvatarUrl() throws ParsingException {
195-
assertIsSecureUrl(extractor.getParentChannelAvatarUrl());
195+
void testParentChannelAvatars() {
196+
defaultTestImageCollection(extractor.getParentChannelAvatars());
196197
}
197198

198199
@Test
199-
public void testAvatarUrl() throws ParsingException {
200-
assertIsSecureUrl(extractor.getAvatarUrl());
200+
public void testAvatars() {
201+
defaultTestImageCollection(extractor.getAvatars());
201202
}
202203

203204
@Test
204-
public void testBannerUrl() throws ParsingException {
205-
assertNull(extractor.getBannerUrl());
205+
public void testBanners() throws ParsingException {
206+
assertEmpty(extractor.getBanners());
206207
}
207208

208209
@Test
@@ -211,10 +212,11 @@ public void testFeedUrl() throws ParsingException {
211212
}
212213

213214
@Test
214-
public void testSubscriberCount() throws ParsingException {
215-
ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
215+
public void testSubscriberCount() {
216+
assertGreaterOrEqual(700, extractor.getSubscriberCount());
216217
}
217218

219+
@Test
218220
@Override
219221
public void testVerified() throws Exception {
220222
assertFalse(extractor.isVerified());

extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.junit.jupiter.api.Assertions.*;
2020
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
21+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestImageCollection;
2122

2223
public class PeertubeCommentsExtractorTest {
2324
public static class Default {
@@ -73,12 +74,12 @@ void testGetCommentsAllData() throws IOException, ExtractionException {
7374
.forEach(commentsInfoItem -> {
7475
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderUrl()));
7576
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderName()));
76-
assertFalse(Utils.isBlank(commentsInfoItem.getUploaderAvatarUrl()));
77+
defaultTestImageCollection(commentsInfoItem.getUploaderAvatars());
7778
assertFalse(Utils.isBlank(commentsInfoItem.getCommentId()));
7879
assertFalse(Utils.isBlank(commentsInfoItem.getCommentText().getContent()));
7980
assertFalse(Utils.isBlank(commentsInfoItem.getName()));
8081
assertFalse(Utils.isBlank(commentsInfoItem.getTextualUploadDate()));
81-
assertFalse(Utils.isBlank(commentsInfoItem.getThumbnailUrl()));
82+
defaultTestImageCollection(commentsInfoItem.getThumbnails());
8283
assertFalse(Utils.isBlank(commentsInfoItem.getUrl()));
8384
assertEquals(-1, commentsInfoItem.getLikeCount());
8485
assertTrue(Utils.isBlank(commentsInfoItem.getTextualLikeCount()));

extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistExtractorTest.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
5+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestImageCollection;
56

67
import org.junit.jupiter.api.BeforeAll;
7-
import org.junit.jupiter.api.Disabled;
88
import org.junit.jupiter.api.Test;
99
import org.schabi.newpipe.downloader.DownloaderTestImpl;
1010
import org.schabi.newpipe.extractor.ExtractorAsserts;
@@ -31,11 +31,8 @@ void testGetName() throws ParsingException {
3131
}
3232

3333
@Test
34-
@Disabled("URL changes with every request")
35-
void testGetThumbnailUrl() throws ParsingException {
36-
assertEquals(
37-
"https://framatube.org/static/thumbnails/playlist-96b0ee2b-a5a7-4794-8769-58d8ccb79ab7.jpg",
38-
extractor.getThumbnailUrl());
34+
void testGetThumbnails() throws ParsingException {
35+
defaultTestImageCollection(extractor.getThumbnails());
3936
}
4037

4138
@Test
@@ -44,10 +41,8 @@ void testGetUploaderUrl() {
4441
}
4542

4643
@Test
47-
void testGetUploaderAvatarUrl() throws ParsingException {
48-
assertEquals(
49-
"https://framatube.org/lazy-static/avatars/c6801ff9-cb49-42e6-b2db-3db623248115.jpg",
50-
extractor.getUploaderAvatarUrl());
44+
void testGetUploaderAvatars() throws ParsingException {
45+
defaultTestImageCollection(extractor.getUploaderAvatars());
5146
}
5247

5348
@Test
@@ -76,10 +71,8 @@ void testGetSubChannelName() {
7671
}
7772

7873
@Test
79-
void testGetSubChannelAvatarUrl() throws ParsingException {
80-
assertEquals(
81-
"https://framatube.org/lazy-static/avatars/e801ccce-8694-4309-b0ab-e6f0e552ef77.png",
82-
extractor.getSubChannelAvatarUrl());
74+
void testGetSubChannelAvatars() throws ParsingException {
75+
defaultTestImageCollection(extractor.getSubChannelAvatars());
8376
}
8477
}
8578
}

0 commit comments

Comments
 (0)