Skip to content

Commit 0ee2072

Browse files
AudricVTheta-Dev
authored andcommitted
[PeerTube] Implement link handlers and channels tabs and tags changes on tests
Co-authored-by: ThetaDev <t.testboy@gmail.com>
1 parent d3801dd commit 0ee2072

5 files changed

Lines changed: 421 additions & 84 deletions

File tree

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

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.schabi.newpipe.downloader.DownloaderTestImpl;
66
import org.schabi.newpipe.extractor.ExtractorAsserts;
77
import org.schabi.newpipe.extractor.NewPipe;
8-
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
8+
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
99
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1010
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
1111
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeAccountExtractor;
@@ -14,11 +14,10 @@
1414
import static org.junit.jupiter.api.Assertions.assertFalse;
1515
import static org.junit.jupiter.api.Assertions.assertNotNull;
1616
import static org.junit.jupiter.api.Assertions.assertNull;
17+
import static org.junit.jupiter.api.Assertions.assertTrue;
1718
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
19+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContained;
1820
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
19-
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor;
20-
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems;
21-
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
2221

2322
/**
2423
* Test for {@link PeertubeAccountExtractor}
@@ -67,20 +66,6 @@ public void testOriginalUrl() throws ParsingException {
6766
assertEquals("https://framatube.org/accounts/framasoft", extractor.getOriginalUrl());
6867
}
6968

70-
/*//////////////////////////////////////////////////////////////////////////
71-
// ListExtractor
72-
//////////////////////////////////////////////////////////////////////////*/
73-
74-
@Test
75-
public void testRelatedItems() throws Exception {
76-
defaultTestRelatedItems(extractor);
77-
}
78-
79-
@Test
80-
public void testMoreRelatedItems() throws Exception {
81-
defaultTestMoreItems(extractor);
82-
}
83-
8469
/*//////////////////////////////////////////////////////////////////////////
8570
// ChannelExtractor
8671
//////////////////////////////////////////////////////////////////////////*/
@@ -114,6 +99,18 @@ public void testSubscriberCount() throws ParsingException {
11499
public void testVerified() throws Exception {
115100
assertFalse(extractor.isVerified());
116101
}
102+
103+
@Test
104+
@Override
105+
public void testTabs() throws Exception {
106+
assertTabsContained(extractor.getTabs(), ChannelTabs.VIDEOS, ChannelTabs.CHANNELS);
107+
}
108+
109+
@Test
110+
@Override
111+
public void testTags() throws Exception {
112+
assertTrue(extractor.getTags().isEmpty());
113+
}
117114
}
118115

119116
public static class FreeSoftwareFoundation implements BaseChannelExtractorTest {
@@ -129,16 +126,6 @@ public static void setUp() throws Exception {
129126
extractor.fetchPage();
130127
}
131128

132-
/*//////////////////////////////////////////////////////////////////////////
133-
// Additional Testing
134-
//////////////////////////////////////////////////////////////////////////*/
135-
136-
@Test
137-
public void testGetPageInNewExtractor() throws Exception {
138-
final ChannelExtractor newExtractor = PeerTube.getChannelExtractor(extractor.getUrl());
139-
defaultTestGetPageInNewExtractor(extractor, newExtractor);
140-
}
141-
142129
/*//////////////////////////////////////////////////////////////////////////
143130
// Extractor
144131
//////////////////////////////////////////////////////////////////////////*/
@@ -168,20 +155,6 @@ public void testOriginalUrl() throws ParsingException {
168155
assertEquals("https://framatube.org/api/v1/accounts/fsf", extractor.getOriginalUrl());
169156
}
170157

171-
/*//////////////////////////////////////////////////////////////////////////
172-
// ListExtractor
173-
//////////////////////////////////////////////////////////////////////////*/
174-
175-
@Test
176-
public void testRelatedItems() throws Exception {
177-
defaultTestRelatedItems(extractor);
178-
}
179-
180-
@Test
181-
public void testMoreRelatedItems() throws Exception {
182-
defaultTestMoreItems(extractor);
183-
}
184-
185158
/*//////////////////////////////////////////////////////////////////////////
186159
// ChannelExtractor
187160
//////////////////////////////////////////////////////////////////////////*/
@@ -215,5 +188,17 @@ public void testSubscriberCount() throws ParsingException {
215188
public void testVerified() throws Exception {
216189
assertFalse(extractor.isVerified());
217190
}
191+
192+
@Test
193+
@Override
194+
public void testTabs() throws Exception {
195+
assertTabsContained(extractor.getTabs(), ChannelTabs.VIDEOS, ChannelTabs.CHANNELS);
196+
}
197+
198+
@Test
199+
@Override
200+
public void testTags() throws Exception {
201+
assertTrue(extractor.getTags().isEmpty());
202+
}
218203
}
219204
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
package org.schabi.newpipe.extractor.services.peertube;
2+
3+
import org.junit.jupiter.api.BeforeAll;
4+
import org.junit.jupiter.api.Test;
5+
import org.schabi.newpipe.downloader.DownloaderTestImpl;
6+
import org.schabi.newpipe.extractor.NewPipe;
7+
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
8+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
9+
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
10+
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelTabExtractor;
11+
12+
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
14+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems;
15+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
16+
17+
class PeertubeAccountTabExtractorTest {
18+
19+
static class Videos implements BaseListExtractorTest {
20+
private static PeertubeChannelTabExtractor extractor;
21+
22+
@BeforeAll
23+
static void setUp() throws Exception {
24+
NewPipe.init(DownloaderTestImpl.getInstance());
25+
// setting instance might break test when running in parallel
26+
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
27+
extractor = (PeertubeChannelTabExtractor) PeerTube
28+
.getChannelTabExtractorFromId("accounts/framasoft", ChannelTabs.VIDEOS);
29+
extractor.fetchPage();
30+
}
31+
32+
/*//////////////////////////////////////////////////////////////////////////
33+
// Extractor
34+
//////////////////////////////////////////////////////////////////////////*/
35+
36+
@Test
37+
@Override
38+
public void testServiceId() {
39+
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
40+
}
41+
42+
@Test
43+
@Override
44+
public void testName() throws ParsingException {
45+
assertEquals(ChannelTabs.VIDEOS, extractor.getName());
46+
}
47+
48+
@Test
49+
@Override
50+
public void testId() throws ParsingException {
51+
assertEquals("accounts/framasoft", extractor.getId());
52+
}
53+
54+
@Test
55+
@Override
56+
public void testUrl() throws ParsingException {
57+
assertEquals("https://framatube.org/accounts/framasoft/videos",
58+
extractor.getUrl());
59+
}
60+
61+
@Test
62+
@Override
63+
public void testOriginalUrl() throws ParsingException {
64+
assertEquals("https://framatube.org/accounts/framasoft/videos",
65+
extractor.getOriginalUrl());
66+
}
67+
68+
/*//////////////////////////////////////////////////////////////////////////
69+
// ListExtractor
70+
//////////////////////////////////////////////////////////////////////////*/
71+
72+
@Test
73+
@Override
74+
public void testRelatedItems() throws Exception {
75+
defaultTestRelatedItems(extractor);
76+
}
77+
78+
@Test
79+
@Override
80+
public void testMoreRelatedItems() throws Exception {
81+
defaultTestMoreItems(extractor);
82+
}
83+
}
84+
85+
static class Channels implements BaseListExtractorTest {
86+
private static PeertubeChannelTabExtractor extractor;
87+
88+
@BeforeAll
89+
static void setUp() throws Exception {
90+
NewPipe.init(DownloaderTestImpl.getInstance());
91+
// setting instance might break test when running in parallel
92+
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
93+
extractor = (PeertubeChannelTabExtractor) PeerTube
94+
.getChannelTabExtractorFromId("accounts/framasoft", ChannelTabs.CHANNELS);
95+
extractor.fetchPage();
96+
}
97+
98+
/*//////////////////////////////////////////////////////////////////////////
99+
// Extractor
100+
//////////////////////////////////////////////////////////////////////////*/
101+
102+
@Test
103+
@Override
104+
public void testServiceId() {
105+
assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
106+
}
107+
108+
@Test
109+
@Override
110+
public void testName() throws ParsingException {
111+
assertEquals(ChannelTabs.CHANNELS, extractor.getName());
112+
}
113+
114+
@Test
115+
@Override
116+
public void testId() throws ParsingException {
117+
assertEquals("accounts/framasoft", extractor.getId());
118+
}
119+
120+
@Test
121+
@Override
122+
public void testUrl() throws ParsingException {
123+
assertEquals("https://framatube.org/accounts/framasoft/video-channels",
124+
extractor.getUrl());
125+
}
126+
127+
@Test
128+
@Override
129+
public void testOriginalUrl() throws ParsingException {
130+
assertEquals("https://framatube.org/accounts/framasoft/video-channels",
131+
extractor.getOriginalUrl());
132+
}
133+
134+
/*//////////////////////////////////////////////////////////////////////////
135+
// ListExtractor
136+
//////////////////////////////////////////////////////////////////////////*/
137+
138+
@Test
139+
@Override
140+
public void testRelatedItems() throws Exception {
141+
defaultTestRelatedItems(extractor);
142+
}
143+
144+
@Test
145+
@Override
146+
public void testMoreRelatedItems() throws Exception {
147+
defaultTestMoreItems(extractor);
148+
}
149+
}
150+
}

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

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
import org.schabi.newpipe.downloader.DownloaderTestImpl;
66
import org.schabi.newpipe.extractor.ExtractorAsserts;
77
import org.schabi.newpipe.extractor.NewPipe;
8-
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
8+
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
99
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1010
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
1111
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelExtractor;
1212

13-
import static org.junit.jupiter.api.Assertions.*;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertFalse;
15+
import static org.junit.jupiter.api.Assertions.assertNotNull;
16+
import static org.junit.jupiter.api.Assertions.assertNull;
17+
import static org.junit.jupiter.api.Assertions.assertTrue;
1418
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
19+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContained;
1520
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
16-
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
1721

1822
/**
1923
* Test for {@link PeertubeChannelExtractor}
@@ -62,20 +66,6 @@ public void testOriginalUrl() throws ParsingException {
6266
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getOriginalUrl());
6367
}
6468

65-
/*//////////////////////////////////////////////////////////////////////////
66-
// ListExtractor
67-
//////////////////////////////////////////////////////////////////////////*/
68-
69-
@Test
70-
public void testRelatedItems() throws Exception {
71-
defaultTestRelatedItems(extractor);
72-
}
73-
74-
@Test
75-
public void testMoreRelatedItems() throws Exception {
76-
defaultTestMoreItems(extractor);
77-
}
78-
7969
/*//////////////////////////////////////////////////////////////////////////
8070
// ChannelExtractor
8171
//////////////////////////////////////////////////////////////////////////*/
@@ -124,6 +114,18 @@ public void testSubscriberCount() throws ParsingException {
124114
public void testVerified() throws Exception {
125115
assertFalse(extractor.isVerified());
126116
}
117+
118+
@Test
119+
@Override
120+
public void testTabs() throws Exception {
121+
assertTabsContained(extractor.getTabs(), ChannelTabs.VIDEOS, ChannelTabs.PLAYLISTS);
122+
}
123+
124+
@Test
125+
@Override
126+
public void testTags() throws Exception {
127+
assertTrue(extractor.getTags().isEmpty());
128+
}
127129
}
128130

129131
public static class ChatSceptique implements BaseChannelExtractorTest {
@@ -140,16 +142,6 @@ public static void setUp() throws Exception {
140142
extractor.fetchPage();
141143
}
142144

143-
/*//////////////////////////////////////////////////////////////////////////
144-
// Additional Testing
145-
//////////////////////////////////////////////////////////////////////////*/
146-
147-
@Test
148-
public void testGetPageInNewExtractor() throws Exception {
149-
final ChannelExtractor newExtractor = PeerTube.getChannelExtractor(extractor.getUrl());
150-
defaultTestGetPageInNewExtractor(extractor, newExtractor);
151-
}
152-
153145
/*//////////////////////////////////////////////////////////////////////////
154146
// Extractor
155147
//////////////////////////////////////////////////////////////////////////*/
@@ -179,20 +171,6 @@ public void testOriginalUrl() throws ParsingException {
179171
assertEquals("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr", extractor.getOriginalUrl());
180172
}
181173

182-
/*//////////////////////////////////////////////////////////////////////////
183-
// ListExtractor
184-
//////////////////////////////////////////////////////////////////////////*/
185-
186-
@Test
187-
public void testRelatedItems() throws Exception {
188-
defaultTestRelatedItems(extractor);
189-
}
190-
191-
@Test
192-
public void testMoreRelatedItems() throws Exception {
193-
defaultTestMoreItems(extractor);
194-
}
195-
196174
/*//////////////////////////////////////////////////////////////////////////
197175
// ChannelExtractor
198176
//////////////////////////////////////////////////////////////////////////*/
@@ -241,5 +219,17 @@ public void testSubscriberCount() throws ParsingException {
241219
public void testVerified() throws Exception {
242220
assertFalse(extractor.isVerified());
243221
}
222+
223+
@Test
224+
@Override
225+
public void testTabs() throws Exception {
226+
assertTabsContained(extractor.getTabs(), ChannelTabs.VIDEOS, ChannelTabs.PLAYLISTS);
227+
}
228+
229+
@Test
230+
@Override
231+
public void testTags() throws Exception {
232+
assertTrue(extractor.getTags().isEmpty());
233+
}
244234
}
245235
}

0 commit comments

Comments
 (0)