From 090dade5b338c278c9a6c8f51c25b6bd2d45d1ed Mon Sep 17 00:00:00 2001 From: TobiGr Date: Sun, 27 Dec 2020 01:03:08 +0100 Subject: [PATCH] [media.ccc.de] Add short test for recent kiosk --- .../MediaCCCRecentListExtractorTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCRecentListExtractorTest.java diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCRecentListExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCRecentListExtractorTest.java new file mode 100644 index 000000000..26d403697 --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCRecentListExtractorTest.java @@ -0,0 +1,41 @@ +package org.schabi.newpipe.extractor.services.media_ccc; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.schabi.newpipe.DownloaderTestImpl; +import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.kiosk.KioskExtractor; +import org.schabi.newpipe.extractor.stream.StreamInfoItem; + +import java.time.OffsetDateTime; +import java.util.List; + +import static org.junit.Assert.*; +import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; + +public class MediaCCCRecentListExtractorTest { + private static KioskExtractor extractor; + + @BeforeClass + public static void setUpClass() throws Exception { + NewPipe.init(DownloaderTestImpl.getInstance()); + extractor = MediaCCC.getKioskList().getExtractorById("recent", null); + extractor.fetchPage(); + } + + @Test + public void testStreamList() throws Exception { + final List items = extractor.getInitialPage().getItems(); + assertEquals(100, items.size()); + for (final StreamInfoItem item: items) { + assertFalse(isNullOrEmpty(item.getName())); + assertTrue(item.getDuration() > 0); + assertTrue(isNullOrEmpty(item.getUploaderName())); // we do not get the uploader name + assertTrue(item.getUploadDate().offsetDateTime().isBefore(OffsetDateTime.now())); + assertTrue(item.getUploadDate().offsetDateTime().isAfter(OffsetDateTime.now().minusYears(1))); + } + } + + +}