Skip to content

Commit fcee247

Browse files
committed
Switched to mockonly tests
* Made the reason why the tests are mockonly mandatory
1 parent 0fceb46 commit fcee247

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

extractor/src/test/java/org/schabi/newpipe/downloader/MockOnly.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@
1717
@Retention(RetentionPolicy.RUNTIME)
1818
@ExtendWith(MockOnlyCondition.class)
1919
public @interface MockOnly {
20+
21+
/**
22+
* The reason why the test is mockonly.
23+
*/
24+
String value();
2025
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeMusicSearchExtractorTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package org.schabi.newpipe.extractor.services.youtube.search;
22

3+
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
4+
import static java.util.Collections.singletonList;
5+
36
import org.junit.jupiter.api.BeforeAll;
47
import org.junit.jupiter.api.Disabled;
58
import org.schabi.newpipe.downloader.DownloaderTestImpl;
9+
import org.schabi.newpipe.downloader.MockOnly;
610
import org.schabi.newpipe.extractor.InfoItem;
711
import org.schabi.newpipe.extractor.NewPipe;
812
import org.schabi.newpipe.extractor.StreamingService;
@@ -14,9 +18,6 @@
1418

1519
import javax.annotation.Nullable;
1620

17-
import static java.util.Collections.singletonList;
18-
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
19-
2021
// Doesn't work with mocks. Makes request with different `dataToSend` I think
2122
public class YoutubeMusicSearchExtractorTest {
2223
public static class MusicSongs extends DefaultSearchExtractorTest {
@@ -130,7 +131,7 @@ public static void setUp() throws Exception {
130131
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.CHANNEL; }
131132
}
132133

133-
@Disabled("Currently constantly switching between \"Did you mean\" and \"Showing results for ...\" occurs")
134+
@MockOnly("Currently constantly switching between \"Did you mean\" and \"Showing results for ...\" occurs")
134135
public static class Suggestion extends DefaultSearchExtractorTest {
135136
private static SearchExtractor extractor;
136137
private static final String QUERY = "megaman x3";

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
package org.schabi.newpipe.extractor.services.youtube.search;
22

3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertNotNull;
6+
import static org.junit.jupiter.api.Assertions.assertTrue;
7+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
8+
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
9+
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoDuplicatedItems;
10+
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.CHANNELS;
11+
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.PLAYLISTS;
12+
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.VIDEOS;
13+
import static java.util.Collections.singletonList;
14+
315
import org.junit.jupiter.api.BeforeAll;
4-
import org.junit.jupiter.api.Disabled;
516
import org.junit.jupiter.api.Test;
617
import org.schabi.newpipe.downloader.DownloaderFactory;
7-
import org.schabi.newpipe.extractor.*;
18+
import org.schabi.newpipe.downloader.MockOnly;
19+
import org.schabi.newpipe.extractor.InfoItem;
20+
import org.schabi.newpipe.extractor.ListExtractor;
21+
import org.schabi.newpipe.extractor.MetaInfo;
22+
import org.schabi.newpipe.extractor.NewPipe;
23+
import org.schabi.newpipe.extractor.StreamingService;
824
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
925
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
1026
import org.schabi.newpipe.extractor.search.SearchExtractor;
@@ -13,7 +29,6 @@
1329
import org.schabi.newpipe.extractor.stream.Description;
1430
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1531

16-
import javax.annotation.Nullable;
1732
import java.io.IOException;
1833
import java.net.MalformedURLException;
1934
import java.net.URL;
@@ -22,13 +37,7 @@
2237
import java.util.List;
2338
import java.util.Random;
2439

25-
import static java.util.Collections.singletonList;
26-
import static org.junit.jupiter.api.Assertions.assertFalse;
27-
import static org.junit.jupiter.api.Assertions.*;
28-
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
29-
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
30-
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoDuplicatedItems;
31-
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.*;
40+
import javax.annotation.Nullable;
3241

3342
public class YoutubeSearchExtractorTest {
3443

@@ -132,7 +141,7 @@ public static void setUp() throws Exception {
132141
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
133142
}
134143

135-
@Disabled("Currently constantly switching between \"Did you mean\" and \"Showing results for ...\" occurs")
144+
@MockOnly("Currently constantly switching between \"Did you mean\" and \"Showing results for ...\" occurs")
136145
public static class Suggestion extends DefaultSearchExtractorTest {
137146
private static SearchExtractor extractor;
138147
private static final String QUERY = "newpip";

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorRelatedMixTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static void setUp() throws Exception {
8888
// @formatter:on
8989

9090
@Test
91-
@MockOnly // related items keep changing, and so do the mixes contained within them
91+
@MockOnly("related items keep changing, and so do the mixes contained within them")
9292
@Override
9393
public void testRelatedItems() throws Exception {
9494
super.testRelatedItems();

0 commit comments

Comments
 (0)