Merge pull request #760 from litetex/fix-test

Fix test
This commit is contained in:
Tobi 2021-12-11 12:44:45 +01:00 committed by GitHub
commit 1e0c409bec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 424 additions and 367 deletions

View File

@ -40,8 +40,8 @@ import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.utils.Utils.*; import static org.schabi.newpipe.extractor.utils.Utils.*;
public class SoundcloudParsingHelper { public class SoundcloudParsingHelper {
private static final String HARDCODED_CLIENT_ID = static final String HARDCODED_CLIENT_ID =
"nGKlrpy2IotLQ0QGwBOmIgSFayis6H4e"; // Updated on 04/11/21 "1NKODbzHzEpoowFHxTAmS7oB08DObPuK"; // Updated on 08/12/21
private static String clientId; private static String clientId;
public static final String SOUNDCLOUD_API_V2_URL = "https://api-v2.soundcloud.com/"; public static final String SOUNDCLOUD_API_V2_URL = "https://api-v2.soundcloud.com/";

View File

@ -5,9 +5,13 @@ import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.IOException;
public class SoundcloudParsingHelperTest { public class SoundcloudParsingHelperTest {
@BeforeClass @BeforeClass
public static void setUp() { public static void setUp() {
@ -20,6 +24,14 @@ public class SoundcloudParsingHelperTest {
SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid()); SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid());
} }
@Test
public void assertHardCodedClientIdMatchesCurrentClientId() throws IOException, ExtractionException {
assertEquals(
"Hardcoded client doesn't match extracted clientId",
SoundcloudParsingHelper.HARDCODED_CLIENT_ID,
SoundcloudParsingHelper.clientId());
}
@Test @Test
public void resolveUrlWithEmbedPlayerTest() throws Exception { public void resolveUrlWithEmbedPlayerTest() throws Exception {
Assert.assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/26057743")); Assert.assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/26057743"));

View File

@ -71,7 +71,7 @@ public class SoundcloudStreamExtractorTest {
@Override public boolean expectedHasSubtitles() { return false; } @Override public boolean expectedHasSubtitles() { return false; }
@Override public boolean expectedHasFrames() { return false; } @Override public boolean expectedHasFrames() { return false; }
@Override public int expectedStreamSegmentsCount() { return 0; } @Override public int expectedStreamSegmentsCount() { return 0; }
@Override public boolean expectedHasRelatedItems() { return false; } @Override public boolean expectedHasRelatedItems() { return true; } // One stream is returned
@Override public String expectedLicence() { return "all-rights-reserved"; } @Override public String expectedLicence() { return "all-rights-reserved"; }
@Override public String expectedCategory() { return "Pop"; } @Override public String expectedCategory() { return "Pop"; }
} }

View File

@ -126,7 +126,7 @@ public class YoutubeChannelExtractorTest {
// "This account has been terminated because we received multiple third-party claims // "This account has been terminated because we received multiple third-party claims
// of copyright infringement regarding material that the user posted." // of copyright infringement regarding material that the user posted."
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCpExuV8qJMfCaSQNL1YG6bQ"); YouTube.getChannelExtractor("https://www.youtube.com/channel/UCI4i4RgFT5ilfMpna4Z_Y8w");
try { try {
extractor.fetchPage(); extractor.fetchPage();
} catch (final AccountTerminatedException e) { } catch (final AccountTerminatedException e) {

View File

@ -308,7 +308,7 @@ public class YoutubeCommentsExtractorTest {
} }
public static class RepliesTest { public static class RepliesTest {
private final static String url = "https://www.youtube.com/watch?v=--yeOvJGZQk"; private final static String url = "https://www.youtube.com/watch?v=xaQJbozY_Is";
private static YoutubeCommentsExtractor extractor; private static YoutubeCommentsExtractor extractor;
@BeforeClass @BeforeClass
@ -329,9 +329,11 @@ public class YoutubeCommentsExtractorTest {
CommentsInfoItem firstComment = comments.getItems().get(0); CommentsInfoItem firstComment = comments.getItems().get(0);
assertTrue("First comment isn't pinned", firstComment.isPinned());
InfoItemsPage<CommentsInfoItem> replies = extractor.getPage(firstComment.getReplies()); InfoItemsPage<CommentsInfoItem> replies = extractor.getPage(firstComment.getReplies());
assertEquals("First reply comment did not match", "Lol", replies.getItems().get(0).getCommentText()); assertEquals("First reply comment did not match", "First", replies.getItems().get(0).getCommentText());
} }
} }
} }

View File

@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.StreamType;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@ -20,7 +21,7 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
public class YoutubeStreamExtractorAgeRestrictedTest extends DefaultStreamExtractorTest { public class YoutubeStreamExtractorAgeRestrictedTest extends DefaultStreamExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/stream/"; private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/stream/";
private static final String ID = "MmBeUZqv1QA"; private static final String ID = "rwcfPqbAx-0";
private static final int TIMESTAMP = 196; private static final int TIMESTAMP = 196;
private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP; private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@ -37,37 +38,34 @@ public class YoutubeStreamExtractorAgeRestrictedTest extends DefaultStreamExtrac
@Override public StreamExtractor extractor() { return extractor; } @Override public StreamExtractor extractor() { return extractor; }
@Override public StreamingService expectedService() { return YouTube; } @Override public StreamingService expectedService() { return YouTube; }
@Override public String expectedName() { return "FINGERING PORNSTARS @ AVN Expo 2017 In Las Vegas!"; } @Override public String expectedName() { return "Russian Daft Punk"; }
@Override public String expectedId() { return ID; } @Override public String expectedId() { return ID; }
@Override public String expectedUrlContains() { return YoutubeStreamExtractorDefaultTest.BASE_URL + ID; } @Override public String expectedUrlContains() { return YoutubeStreamExtractorDefaultTest.BASE_URL + ID; }
@Override public String expectedOriginalUrlContains() { return URL; } @Override public String expectedOriginalUrlContains() { return URL; }
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; } @Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
@Override public String expectedUploaderName() { return "EpicFiveTV"; } @Override public String expectedUploaderName() { return "DAN TV"; }
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCuPUHlLP5POZphOIrjrNxiw"; } @Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCcQHIVL83g5BEQe2IJFb-6w"; }
@Override public boolean expectedUploaderVerified() { return true; } @Override public boolean expectedUploaderVerified() { return false; }
@Override public List<String> expectedDescriptionContains() { return Arrays.asList("http://instagram.com/Ruben_Sole", "AVN"); } @Override public boolean expectedDescriptionIsEmpty() { return true; }
@Override public long expectedLength() { return 1790; } @Override public List<String> expectedDescriptionContains() { return Collections.emptyList(); }
@Override public long expectedLength() { return 10; }
@Override public long expectedTimestamp() { return TIMESTAMP; } @Override public long expectedTimestamp() { return TIMESTAMP; }
@Override public long expectedViewCountAtLeast() { return 28500000; } @Override public long expectedViewCountAtLeast() { return 232_000; }
@Nullable @Override public String expectedUploadDate() { return "2017-01-25 00:00:00.000"; } @Nullable @Override public String expectedUploadDate() { return "2018-03-11 00:00:00.000"; }
@Nullable @Override public String expectedTextualUploadDate() { return "2017-01-25"; } @Nullable @Override public String expectedTextualUploadDate() { return "2018-03-11"; }
@Override public long expectedLikeCountAtLeast() { return 149000; } @Override public long expectedLikeCountAtLeast() { return 3_700; }
@Override public long expectedDislikeCountAtLeast() { return 38000; } @Override public long expectedDislikeCountAtLeast() { return 30; }
@Override public boolean expectedHasRelatedItems() { return false; } // no related videos (!) @Override public boolean expectedHasRelatedItems() { return false; } // no related videos (!)
@Override public int expectedAgeLimit() { return 18; } @Override public int expectedAgeLimit() { return 18; }
@Override public boolean expectedHasSubtitles() { return false; } @Override public boolean expectedHasSubtitles() { return false; }
@Override public boolean expectedHasFrames() { return false; }
@Override public String expectedCategory() { return "Entertainment"; } @Override public String expectedCategory() { return "People & Blogs"; }
@Override public String expectedLicence() { return "YouTube licence"; } @Override public String expectedLicence() { return "YouTube licence"; }
@Override @Override
public List<String> expectedTags() { public List<String> expectedTags() {
return Arrays.asList("AEE", "AEE 2017", "AVN", "AVN 2016", "AVN 2017", "AVN 2017 Expo In Las Vegas", return Collections.emptyList();
"AVN Awards Show", "AVN Expo", "AVN Las Vegas", "AVN Magazine", "AVN Vlog", "Ariana Marie",
"August Ames", "Brenna Sparks", "CeCe Capella", "Cindy Starfall", "Elsa Jean", "Emma Hix",
"FINGERING", "FINGERING P0RNSTARS", "FINGERING PORNSTARS", "Kaho Shibuya", "Keisha Grey",
"Kimberly Chi", "Las Vegas", "Mia Martinez", "Pornstar", "Pornstars", "Riley Reid",
"Samantha Saint", "Vegas", "Vicki Chase");
} }
} }

View File

@ -53,7 +53,7 @@ public class YoutubeStreamExtractorLivestreamTest extends DefaultStreamExtractor
@Override public String expectedUploaderName() { return "Lofi Girl"; } @Override public String expectedUploaderName() { return "Lofi Girl"; }
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow"; } @Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow"; }
@Override public List<String> expectedDescriptionContains() { @Override public List<String> expectedDescriptionContains() {
return Arrays.asList("https://bit.ly/lofigirI-merch", return Arrays.asList("Lofi Girl merch",
"Thank you for listening, I hope you will have a good time here"); "Thank you for listening, I hope you will have a good time here");
} }
@Override public boolean expectedUploaderVerified() { return true; } @Override public boolean expectedUploaderVerified() { return true; }

View File

@ -221,7 +221,7 @@
"responseMessage": "", "responseMessage": "",
"responseHeaders": { "responseHeaders": {
"alt-svc": [ "alt-svc": [
"h3\u003d\":443\"; ma\u003d2592000,h3-29\u003d\":443\"; ma\u003d2592000,h3-T051\u003d\":443\"; ma\u003d2592000,h3-Q050\u003d\":443\"; ma\u003d2592000,h3-Q046\u003d\":443\"; ma\u003d2592000,h3-Q043\u003d\":443\"; ma\u003d2592000,quic\u003d\":443\"; ma\u003d2592000; v\u003d\"46,43\"" "h3\u003d\":443\"; ma\u003d2592000,h3-29\u003d\":443\"; ma\u003d2592000,h3-Q050\u003d\":443\"; ma\u003d2592000,h3-Q046\u003d\":443\"; ma\u003d2592000,h3-Q043\u003d\":443\"; ma\u003d2592000,quic\u003d\":443\"; ma\u003d2592000; v\u003d\"46,43\""
], ],
"cache-control": [ "cache-control": [
"private" "private"
@ -230,7 +230,7 @@
"application/json; charset\u003dUTF-8" "application/json; charset\u003dUTF-8"
], ],
"date": [ "date": [
"Fri, 30 Jul 2021 17:13:39 GMT" "Wed, 08 Dec 2021 20:50:38 GMT"
], ],
"server": [ "server": [
"ESF" "ESF"