2019-12-22 02:55:54 +01:00
|
|
|
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later
|
|
|
|
|
2019-12-22 00:42:26 +01:00
|
|
|
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 00:42:26 +01:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2020-04-20 22:06:48 +02:00
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
2023-04-14 14:10:26 +02:00
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
|
2023-03-22 01:00:05 +01:00
|
|
|
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
2020-05-25 20:22:23 +02:00
|
|
|
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
2019-12-22 00:42:26 +01:00
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
import java.util.Set;
|
|
|
|
import java.util.stream.Collectors;
|
2020-05-25 20:22:23 +02:00
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
2020-04-20 21:55:35 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
2023-04-14 14:10:26 +02:00
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
2019-12-22 00:42:26 +01:00
|
|
|
|
2020-05-25 20:22:23 +02:00
|
|
|
public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
|
2019-12-22 00:42:26 +01:00
|
|
|
|
2020-05-25 20:22:23 +02:00
|
|
|
private static ChannelExtractor extractor;
|
2023-04-14 14:10:26 +02:00
|
|
|
private static ChannelTabExtractor tabExtractor;
|
2019-12-22 00:42:26 +01:00
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2019-12-22 00:42:26 +01:00
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
2020-11-27 16:48:06 +01:00
|
|
|
extractor = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases");
|
2020-04-20 22:06:48 +02:00
|
|
|
extractor.fetchPage();
|
2019-12-22 00:42:26 +01:00
|
|
|
|
2023-04-14 14:10:26 +02:00
|
|
|
tabExtractor = Bandcamp.getChannelTabExtractor(extractor.getTabs().get(0));
|
|
|
|
tabExtractor.fetchPage();
|
2019-12-22 00:42:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testDescription() throws Exception {
|
2020-11-27 16:48:06 +01:00
|
|
|
assertEquals("making music:)", extractor.getDescription());
|
2019-12-22 00:42:26 +01:00
|
|
|
}
|
2019-12-22 01:05:34 +01:00
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testAvatarUrl() throws Exception {
|
2021-12-27 21:08:08 +01:00
|
|
|
assertTrue(extractor.getAvatarUrl().contains("://f4.bcbits.com/"), "unexpected avatar URL");
|
2019-12-22 01:05:34 +01:00
|
|
|
}
|
2019-12-22 01:38:48 +01:00
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testBannerUrl() throws Exception {
|
2021-12-27 21:08:08 +01:00
|
|
|
assertTrue(extractor.getBannerUrl().contains("://f4.bcbits.com/"), "unexpected banner URL");
|
2019-12-22 01:38:48 +01:00
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testFeedUrl() throws Exception {
|
|
|
|
assertNull(extractor.getFeedUrl());
|
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testSubscriberCount() throws Exception {
|
|
|
|
assertEquals(-1, extractor.getSubscriberCount());
|
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2021-02-19 15:51:02 +01:00
|
|
|
public void testVerified() throws Exception {
|
|
|
|
assertFalse(extractor.isVerified());
|
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2022-10-22 15:28:48 +02:00
|
|
|
public void testTabs() throws Exception {
|
2023-03-22 01:00:05 +01:00
|
|
|
Set<String> tabs = extractor.getTabs().stream()
|
|
|
|
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
|
2023-04-14 14:10:26 +02:00
|
|
|
assertTrue(tabs.contains(ChannelTabs.TRACKS));
|
2023-03-22 01:00:05 +01:00
|
|
|
assertTrue(tabs.contains(ChannelTabs.ALBUMS));
|
2022-10-22 15:28:48 +02:00
|
|
|
}
|
|
|
|
|
2020-05-25 20:22:23 +02:00
|
|
|
@Override
|
|
|
|
public void testRelatedItems() throws Exception {
|
2023-04-14 14:10:26 +02:00
|
|
|
defaultTestRelatedItems(tabExtractor);
|
2020-05-25 20:22:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
|
|
|
// not implemented
|
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-11-19 22:33:52 +01:00
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
|
2020-05-25 20:22:23 +02:00
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testName() throws Exception {
|
2020-11-27 16:48:06 +01:00
|
|
|
assertEquals("toupie", extractor.getName());
|
2020-05-25 20:22:23 +02:00
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testId() throws Exception {
|
2023-03-22 01:00:05 +01:00
|
|
|
assertEquals("2450875064", extractor.getId());
|
2020-05-25 20:22:23 +02:00
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testUrl() throws Exception {
|
2020-11-27 16:48:06 +01:00
|
|
|
assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
|
2020-05-25 20:22:23 +02:00
|
|
|
}
|
|
|
|
|
2023-03-22 01:00:05 +01:00
|
|
|
@Test
|
2020-05-25 20:22:23 +02:00
|
|
|
public void testOriginalUrl() throws Exception {
|
2020-11-27 16:48:06 +01:00
|
|
|
assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
|
2019-12-22 01:38:48 +01:00
|
|
|
}
|
2019-12-22 00:42:26 +01:00
|
|
|
}
|