2019-12-22 15:15:12 +01:00
|
|
|
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later
|
|
|
|
|
|
|
|
package org.schabi.newpipe.extractor.services.bandcamp;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
|
|
import org.junit.jupiter.api.Test;
|
2021-01-15 21:55:40 +01:00
|
|
|
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
2019-12-22 15:15:12 +01:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2021-03-28 12:53:05 +02:00
|
|
|
import org.schabi.newpipe.extractor.Page;
|
2019-12-22 15:15:12 +01:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
2020-05-25 18:51:31 +02:00
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
2020-11-19 22:33:52 +01:00
|
|
|
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
|
|
|
import org.schabi.newpipe.extractor.services.DefaultTests;
|
2019-12-22 15:15:12 +01:00
|
|
|
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampFeaturedExtractor;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.List;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
2020-04-20 21:55:35 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
2019-12-22 15:15:12 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests for {@link BandcampFeaturedExtractor}
|
|
|
|
*/
|
2020-11-19 22:33:52 +01:00
|
|
|
public class BandcampFeaturedExtractorTest implements BaseListExtractorTest {
|
2019-12-22 15:15:12 +01:00
|
|
|
|
|
|
|
private static BandcampFeaturedExtractor extractor;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2019-12-22 15:15:12 +01:00
|
|
|
public static void setUp() throws ExtractionException, IOException {
|
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
2020-04-20 21:55:35 +02:00
|
|
|
extractor = (BandcampFeaturedExtractor) Bandcamp
|
2019-12-22 15:15:12 +01:00
|
|
|
.getKioskList().getDefaultKioskExtractor();
|
2021-02-16 21:09:35 +01:00
|
|
|
extractor.fetchPage();
|
2019-12-22 15:15:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-12-22 17:30:22 +01:00
|
|
|
public void testFeaturedCount() throws ExtractionException, IOException {
|
2020-11-24 09:55:41 +01:00
|
|
|
final List<PlaylistInfoItem> list = extractor.getInitialPage().getItems();
|
2021-03-28 12:53:05 +02:00
|
|
|
assertTrue(list.size() > 5);
|
2019-12-22 15:15:12 +01:00
|
|
|
}
|
|
|
|
|
2020-08-02 16:55:18 +02:00
|
|
|
@Test
|
|
|
|
public void testHttps() throws ExtractionException, IOException {
|
2020-11-24 09:55:41 +01:00
|
|
|
final List<PlaylistInfoItem> list = extractor.getInitialPage().getItems();
|
2020-08-02 16:55:18 +02:00
|
|
|
assertTrue(list.get(0).getUrl().contains("https://"));
|
|
|
|
}
|
|
|
|
|
2021-03-28 12:53:05 +02:00
|
|
|
@Test
|
|
|
|
public void testMorePages() throws ExtractionException, IOException {
|
|
|
|
|
|
|
|
final Page page2 = extractor.getInitialPage().getNextPage();
|
|
|
|
final Page page3 = extractor.getPage(page2).getNextPage();
|
|
|
|
|
|
|
|
assertTrue(extractor.getPage(page2).getItems().size() > 5);
|
|
|
|
|
|
|
|
// Compare first item of second page with first item of third page
|
|
|
|
assertNotEquals(
|
|
|
|
extractor.getPage(page2).getItems().get(0),
|
|
|
|
extractor.getPage(page3).getItems().get(0)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-19 22:33:52 +01:00
|
|
|
@Override
|
|
|
|
public void testRelatedItems() throws Exception {
|
|
|
|
DefaultTests.defaultTestRelatedItems(extractor);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
|
|
|
// more items not implemented
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testName() throws Exception {
|
|
|
|
assertEquals("Featured", extractor.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testId() {
|
|
|
|
assertEquals("", extractor.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testUrl() throws Exception {
|
|
|
|
assertEquals("", extractor.getUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testOriginalUrl() throws Exception {
|
|
|
|
assertEquals("", extractor.getOriginalUrl());
|
|
|
|
}
|
2019-12-22 15:15:12 +01:00
|
|
|
}
|