From 00a0f1a103daf4bd83c6a7d043ea39c7a0d1a0ad Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Thu, 30 Nov 2023 22:09:39 +0100 Subject: [PATCH] [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. --- .../search/YoutubeSearchExtractorTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java index 4720aaa36..d6705d615 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java @@ -414,4 +414,37 @@ public class YoutubeSearchExtractorTest { .anyMatch(StreamInfoItem::isShortFormContent)); } } + + /** + * A {@link SearchExtractor} test to check if crisis resources preventing search results to be + * returned are bypassed (searches with content filters are not tested in this test, even if + * they should work as bypasses are used with them too). + * + *

+ * See + * https://support.google.com/youtube/answer/10726080?hl=en for more info on crisis + * resources. + *

+ */ + public static class CrisisResources extends DefaultSearchExtractorTest { + private static SearchExtractor extractor; + private static final String QUERY = "blue whale"; + + @BeforeAll + public static void setUp() throws Exception { + YoutubeTestsUtils.ensureStateless(); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "crisis_resources")); + extractor = YouTube.getSearchExtractor(QUERY); + extractor.fetchPage(); + } + + @Override public SearchExtractor extractor() { return extractor; } + @Override public StreamingService expectedService() { return YouTube; } + @Override public String expectedName() { return QUERY; } + @Override public String expectedId() { return QUERY; } + @Override public String expectedUrlContains() throws Exception { return "youtube.com/results?search_query=" + Utils.encodeUrlUtf8(QUERY); } + @Override public String expectedOriginalUrlContains() throws Exception { return "youtube.com/results?search_query=" + Utils.encodeUrlUtf8(QUERY); } + @Override public String expectedSearchString() { return QUERY; } + @Nullable @Override public String expectedSearchSuggestion() { return null; } + } }