Add method to allow resetting youtube client version and key
This is needed so that a request is made for each test class when running multiple at once. This way RecordingDownloader records all necessary requests. This works as long as tests are run sequentially and not in parallel.
This commit is contained in:
parent
f447a7a450
commit
35e299759e
|
@ -353,6 +353,11 @@ public class YoutubeParsingHelper {
|
|||
return key;
|
||||
}
|
||||
|
||||
static void resetClientVersionAndKey() {
|
||||
clientVersion = null;
|
||||
key = null;
|
||||
}
|
||||
|
||||
public static boolean areHardcodedYoutubeMusicKeysValid() throws IOException, ReCaptchaException {
|
||||
final String url = "https://music.youtube.com/youtubei/v1/search?alt=json&key=" + HARDCODED_YOUTUBE_MUSIC_KEYS[0];
|
||||
|
||||
|
|
|
@ -31,15 +31,6 @@ class MockDownloader extends Downloader {
|
|||
reader.close();
|
||||
mocks.put(response.getRequest(), response.getResponse());
|
||||
}
|
||||
|
||||
//shared find proper solution
|
||||
File clientVersion = new File("src/test/resources/org/schabi/newpipe/extractor/services/youtube/client_version.json");
|
||||
final FileReader reader = new FileReader(clientVersion);
|
||||
final TestRequestResponse response = new GsonBuilder()
|
||||
.create()
|
||||
.fromJson(reader, TestRequestResponse.class);
|
||||
reader.close();
|
||||
mocks.put(response.getRequest(), response.getResponse());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,6 +53,7 @@ public class YoutubeMixPlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
final File file = new File(RESOURCE_PATH + "mix");
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath()));
|
||||
extractor = (YoutubeMixPlaylistExtractor) YouTube
|
||||
|
@ -131,6 +132,7 @@ public class YoutubeMixPlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
final File file = new File(RESOURCE_PATH + "mixWithIndex");
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath()));
|
||||
extractor = (YoutubeMixPlaylistExtractor) YouTube
|
||||
|
@ -201,6 +203,7 @@ public class YoutubeMixPlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
final File file = new File(RESOURCE_PATH + "myMix");
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath()));
|
||||
extractor = (YoutubeMixPlaylistExtractor) YouTube
|
||||
|
@ -274,6 +277,7 @@ public class YoutubeMixPlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws IOException {
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
final File file = new File(RESOURCE_PATH + "invalid");
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath()));
|
||||
}
|
||||
|
@ -306,6 +310,7 @@ public class YoutubeMixPlaylistExtractorTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
final File file = new File(RESOURCE_PATH + "channelMix");
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(file.getAbsolutePath()));
|
||||
extractor = (YoutubeMixPlaylistExtractor) YouTube
|
||||
|
|
Loading…
Reference in New Issue