Skip to content

Commit

Permalink
Merge pull request #760 from litetex/fix-test
Browse files Browse the repository at this point in the history
Fix test
  • Loading branch information
TobiGr authored Dec 11, 2021
2 parents f6f2724 + d9b2a20 commit 1e0c409
Show file tree
Hide file tree
Showing 27 changed files with 420 additions and 363 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import static org.schabi.newpipe.extractor.utils.Utils.*;

public class SoundcloudParsingHelper {
private static final String HARDCODED_CLIENT_ID =
"nGKlrpy2IotLQ0QGwBOmIgSFayis6H4e"; // Updated on 04/11/21
static final String HARDCODED_CLIENT_ID =
"1NKODbzHzEpoowFHxTAmS7oB08DObPuK"; // Updated on 08/12/21
private static String clientId;
public static final String SOUNDCLOUD_API_V2_URL = "https://api-v2.soundcloud.com/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
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 java.io.IOException;

public class SoundcloudParsingHelperTest {
@BeforeClass
public static void setUp() {
Expand All @@ -20,6 +24,14 @@ public void assertThatHardcodedClientIdIsValid() throws Exception {
SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid());
}

@Test
public void assertHardCodedClientIdMatchesCurrentClientId() throws IOException, ExtractionException {
assertEquals(
"Hardcoded client doesn't match extracted clientId",
SoundcloudParsingHelper.HARDCODED_CLIENT_ID,
SoundcloudParsingHelper.clientId());
}

@Test
public void resolveUrlWithEmbedPlayerTest() throws Exception {
Assert.assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/26057743"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void setUp() throws Exception {
@Override public boolean expectedHasSubtitles() { return false; }
@Override public boolean expectedHasFrames() { return false; }
@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 expectedCategory() { return "Pop"; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void accountTerminatedCopyrightFetch() throws Exception {
// "This account has been terminated because we received multiple third-party claims
// of copyright infringement regarding material that the user posted."
final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCpExuV8qJMfCaSQNL1YG6bQ");
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCI4i4RgFT5ilfMpna4Z_Y8w");
try {
extractor.fetchPage();
} catch (final AccountTerminatedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void testGetCommentsFirst() throws IOException, ExtractionException {
}

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;

@BeforeClass
Expand All @@ -329,9 +329,11 @@ public void testGetCommentsFirstReplies() throws IOException, ExtractionExceptio

CommentsInfoItem firstComment = comments.getItems().get(0);

assertTrue("First comment isn't pinned", firstComment.isPinned());

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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.schabi.newpipe.extractor.stream.StreamType;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

Expand All @@ -20,7 +21,7 @@

public class YoutubeStreamExtractorAgeRestrictedTest extends DefaultStreamExtractorTest {
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 String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP;
private static StreamExtractor extractor;
Expand All @@ -37,37 +38,34 @@ public static void setUp() throws Exception {

@Override public StreamExtractor extractor() { return extractor; }
@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 expectedUrlContains() { return YoutubeStreamExtractorDefaultTest.BASE_URL + ID; }
@Override public String expectedOriginalUrlContains() { return URL; }

@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
@Override public String expectedUploaderName() { return "EpicFiveTV"; }
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCuPUHlLP5POZphOIrjrNxiw"; }
@Override public boolean expectedUploaderVerified() { return true; }
@Override public List<String> expectedDescriptionContains() { return Arrays.asList("http://instagram.com/Ruben_Sole", "AVN"); }
@Override public long expectedLength() { return 1790; }
@Override public String expectedUploaderName() { return "DAN TV"; }
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCcQHIVL83g5BEQe2IJFb-6w"; }
@Override public boolean expectedUploaderVerified() { return false; }
@Override public boolean expectedDescriptionIsEmpty() { return true; }
@Override public List<String> expectedDescriptionContains() { return Collections.emptyList(); }
@Override public long expectedLength() { return 10; }
@Override public long expectedTimestamp() { return TIMESTAMP; }
@Override public long expectedViewCountAtLeast() { return 28500000; }
@Nullable @Override public String expectedUploadDate() { return "2017-01-25 00:00:00.000"; }
@Nullable @Override public String expectedTextualUploadDate() { return "2017-01-25"; }
@Override public long expectedLikeCountAtLeast() { return 149000; }
@Override public long expectedDislikeCountAtLeast() { return 38000; }
@Override public long expectedViewCountAtLeast() { return 232_000; }
@Nullable @Override public String expectedUploadDate() { return "2018-03-11 00:00:00.000"; }
@Nullable @Override public String expectedTextualUploadDate() { return "2018-03-11"; }
@Override public long expectedLikeCountAtLeast() { return 3_700; }
@Override public long expectedDislikeCountAtLeast() { return 30; }
@Override public boolean expectedHasRelatedItems() { return false; } // no related videos (!)
@Override public int expectedAgeLimit() { return 18; }
@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 List<String> expectedTags() {
return Arrays.asList("AEE", "AEE 2017", "AVN", "AVN 2016", "AVN 2017", "AVN 2017 Expo In Las Vegas",
"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");
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testUploaderName() throws Exception {
@Override public String expectedUploaderName() { return "Lofi Girl"; }
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow"; }
@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");
}
@Override public boolean expectedUploaderVerified() { return true; }
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"responseMessage": "",
"responseHeaders": {
"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": [
"private"
Expand All @@ -230,7 +230,7 @@
"application/json; charset\u003dUTF-8"
],
"date": [
"Fri, 30 Jul 2021 17:13:39 GMT"
"Wed, 08 Dec 2021 20:50:38 GMT"
],
"server": [
"ESF"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 1e0c409

Please sign in to comment.