Skip to content

Commit 00a0f1a

Browse files
committed
[YouTube] Add a blocking crisis resources bypass in search results test
This test only tests that search results are returned, when no content filters are provided and crisis resources blocking search results should be returned. Searches with blocking crisis resources and content filters should work too, as the bypass has been implemented for them.
1 parent 06838d7 commit 00a0f1a

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,4 +414,37 @@ void testShortFormContent() throws IOException, ExtractionException {
414414
.anyMatch(StreamInfoItem::isShortFormContent));
415415
}
416416
}
417+
418+
/**
419+
* A {@link SearchExtractor} test to check if crisis resources preventing search results to be
420+
* returned are bypassed (searches with content filters are not tested in this test, even if
421+
* they should work as bypasses are used with them too).
422+
*
423+
* <p>
424+
* See <a href="https://support.google.com/youtube/answer/10726080?hl=en">
425+
* https://support.google.com/youtube/answer/10726080?hl=en</a> for more info on crisis
426+
* resources.
427+
* </p>
428+
*/
429+
public static class CrisisResources extends DefaultSearchExtractorTest {
430+
private static SearchExtractor extractor;
431+
private static final String QUERY = "blue whale";
432+
433+
@BeforeAll
434+
public static void setUp() throws Exception {
435+
YoutubeTestsUtils.ensureStateless();
436+
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "crisis_resources"));
437+
extractor = YouTube.getSearchExtractor(QUERY);
438+
extractor.fetchPage();
439+
}
440+
441+
@Override public SearchExtractor extractor() { return extractor; }
442+
@Override public StreamingService expectedService() { return YouTube; }
443+
@Override public String expectedName() { return QUERY; }
444+
@Override public String expectedId() { return QUERY; }
445+
@Override public String expectedUrlContains() throws Exception { return "youtube.com/results?search_query=" + Utils.encodeUrlUtf8(QUERY); }
446+
@Override public String expectedOriginalUrlContains() throws Exception { return "youtube.com/results?search_query=" + Utils.encodeUrlUtf8(QUERY); }
447+
@Override public String expectedSearchString() { return QUERY; }
448+
@Nullable @Override public String expectedSearchSuggestion() { return null; }
449+
}
417450
}

0 commit comments

Comments
 (0)