Fixed test: Peertube - Use new comments and videos

Old comments/videos got deleted
This commit is contained in:
litetex 2022-03-14 21:23:31 +01:00
parent 606a386a98
commit 2bd4299563
1 changed files with 16 additions and 11 deletions

View File

@ -28,34 +28,39 @@ public class PeertubeCommentsExtractorTest {
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (PeertubeCommentsExtractor) PeerTube extractor = (PeertubeCommentsExtractor) PeerTube
.getCommentsExtractor("https://framatube.org/videos/watch/9c9de5e8-0a1e-484a-b099-e80766180a6d"); .getCommentsExtractor("https://framatube.org/w/kkGMgK9ZtnKfYAgnEtQxbv");
} }
@Test @Test
public void testGetComments() throws IOException, ExtractionException { void testGetComments() throws IOException, ExtractionException {
final String comment = "I love this";
InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage(); InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
boolean result = findInComments(comments, "Cool."); boolean result = findInComments(comments, comment);
while (comments.hasNextPage() && !result) { while (comments.hasNextPage() && !result) {
comments = extractor.getPage(comments.getNextPage()); comments = extractor.getPage(comments.getNextPage());
result = findInComments(comments, "Cool."); result = findInComments(comments, comment);
} }
assertTrue(result); assertTrue(result);
} }
@Test @Test
public void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException { void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException {
CommentsInfo commentsInfo = CommentsInfo.getInfo("https://framatube.org/videos/watch/217eefeb-883d-45be-b7fc-a788ad8507d3"); final String comment = "great video";
final CommentsInfo commentsInfo =
CommentsInfo.getInfo("https://framatube.org/w/kkGMgK9ZtnKfYAgnEtQxbv");
assertEquals("Comments", commentsInfo.getName()); assertEquals("Comments", commentsInfo.getName());
boolean result = findInComments(commentsInfo.getRelatedItems(), "Cool"); boolean result = findInComments(commentsInfo.getRelatedItems(), comment);
Page nextPage = commentsInfo.getNextPage(); Page nextPage = commentsInfo.getNextPage();
InfoItemsPage<CommentsInfoItem> moreItems = new InfoItemsPage<>(null, nextPage, null); InfoItemsPage<CommentsInfoItem> moreItems = new InfoItemsPage<>(null, nextPage, null);
while (moreItems.hasNextPage() && !result) { while (moreItems.hasNextPage() && !result) {
moreItems = CommentsInfo.getMoreItems(PeerTube, commentsInfo, nextPage); moreItems = CommentsInfo.getMoreItems(PeerTube, commentsInfo, nextPage);
result = findInComments(moreItems.getItems(), "Cool"); result = findInComments(moreItems.getItems(), comment);
nextPage = moreItems.getNextPage(); nextPage = moreItems.getNextPage();
} }
@ -63,7 +68,7 @@ public class PeertubeCommentsExtractorTest {
} }
@Test @Test
public void testGetCommentsAllData() throws IOException, ExtractionException { void testGetCommentsAllData() throws IOException, ExtractionException {
InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage(); InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
for (CommentsInfoItem c : comments.getItems()) { for (CommentsInfoItem c : comments.getItems()) {
assertFalse(Utils.isBlank(c.getUploaderUrl())); assertFalse(Utils.isBlank(c.getUploaderUrl()));
@ -105,13 +110,13 @@ public class PeertubeCommentsExtractorTest {
} }
@Test @Test
public void testGetComments() throws IOException, ExtractionException { void testGetComments() throws IOException, ExtractionException {
final InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage(); final InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
assertTrue(comments.getErrors().isEmpty()); assertTrue(comments.getErrors().isEmpty());
} }
@Test @Test
public void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException { void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException {
final CommentsInfo commentsInfo = CommentsInfo.getInfo("https://framatube.org/videos/watch/217eefeb-883d-45be-b7fc-a788ad8507d3"); final CommentsInfo commentsInfo = CommentsInfo.getInfo("https://framatube.org/videos/watch/217eefeb-883d-45be-b7fc-a788ad8507d3");
assertTrue(commentsInfo.getErrors().isEmpty()); assertTrue(commentsInfo.getErrors().isEmpty());
} }