[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.
This commit is contained in:
AudricV 2023-11-30 22:09:39 +01:00
parent 06838d7245
commit 00a0f1a103
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
1 changed files with 33 additions and 0 deletions

View File

@ -414,4 +414,37 @@ public class YoutubeSearchExtractorTest {
.anyMatch(StreamInfoItem::isShortFormContent)); .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).
*
* <p>
* See <a href="https://support.google.com/youtube/answer/10726080?hl=en">
* https://support.google.com/youtube/answer/10726080?hl=en</a> for more info on crisis
* resources.
* </p>
*/
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; }
}
} }