Skip to content

Commit 8baec04

Browse files
AudricVTheta-Dev
authored andcommitted
[Bandcamp] Implement link handlers and channels tabs and tags changes on tests
Tests in BandcampChannelExtractorTest and BandcampChannelLinkHandlerFactoryTest have been also fixed. Co-authored-by: ThetaDev <t.testboy@gmail.com>
1 parent e0ba29c commit 8baec04

7 files changed

Lines changed: 152 additions & 29 deletions

extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
import org.schabi.newpipe.downloader.DownloaderTestImpl;
88
import org.schabi.newpipe.extractor.NewPipe;
99
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
10-
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
10+
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
1111
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
1212

13-
import java.io.IOException;
14-
1513
import static org.junit.jupiter.api.Assertions.*;
14+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContained;
1615
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
1716

1817
public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
@@ -27,12 +26,7 @@ public static void setUp() throws Exception {
2726
}
2827

2928
@Test
30-
public void testLength() throws ExtractionException, IOException {
31-
assertTrue(extractor.getInitialPage().getItems().size() >= 0);
32-
}
33-
3429
@Override
35-
@Test
3630
public void testDescription() throws Exception {
3731
assertEquals("making music:)", extractor.getDescription());
3832
}
@@ -62,16 +56,6 @@ public void testVerified() throws Exception {
6256
assertFalse(extractor.isVerified());
6357
}
6458

65-
@Override
66-
public void testRelatedItems() throws Exception {
67-
// not implemented
68-
}
69-
70-
@Override
71-
public void testMoreRelatedItems() throws Exception {
72-
// not implemented
73-
}
74-
7559
@Override
7660
public void testServiceId() {
7761
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
@@ -84,7 +68,7 @@ public void testName() throws Exception {
8468

8569
@Override
8670
public void testId() throws Exception {
87-
assertEquals("https://toupie.bandcamp.com/", extractor.getId());
71+
assertEquals("2450875064", extractor.getId());
8872
}
8973

9074
@Override
@@ -96,4 +80,16 @@ public void testUrl() throws Exception {
9680
public void testOriginalUrl() throws Exception {
9781
assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
9882
}
83+
84+
@Test
85+
@Override
86+
public void testTabs() throws Exception {
87+
assertTabsContained(extractor.getTabs(), ChannelTabs.ALBUMS);
88+
}
89+
90+
@Test
91+
@Override
92+
public void testTags() throws Exception {
93+
assertTrue(extractor.getTags().isEmpty());
94+
}
9995
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelLinkHandlerFactoryTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class BandcampChannelLinkHandlerFactoryTest {
1919

2020
@BeforeAll
2121
public static void setUp() {
22-
linkHandler = new BandcampChannelLinkHandlerFactory();
22+
linkHandler = BandcampChannelLinkHandlerFactory.getInstance();
2323
NewPipe.init(DownloaderTestImpl.getInstance());
2424
}
2525

@@ -55,7 +55,7 @@ public void testAcceptUrl() throws ParsingException {
5555
public void testGetId() throws ParsingException {
5656
assertEquals("1196681540", linkHandler.getId("https://macbenson.bandcamp.com/"));
5757
assertEquals("1196681540", linkHandler.getId("http://macbenson.bandcamp.com/"));
58-
assertEquals("1581461772", linkHandler.getId("https://interovgm.bandcamp.com/releases"));
58+
assertEquals("1581461772", linkHandler.getId("https://shirakumon.bandcamp.com/releases"));
5959
assertEquals("3321800855", linkHandler.getId("https://infiniteammo.bandcamp.com/"));
6060
assertEquals("3775652329", linkHandler.getId("https://npet.bandcamp.com/"));
6161

@@ -67,7 +67,7 @@ public void testGetId() throws ParsingException {
6767
@Test
6868
public void testGetUrl() throws ParsingException {
6969
assertEquals("https://macbenson.bandcamp.com", linkHandler.getUrl("1196681540"));
70-
assertEquals("https://interovgm.bandcamp.com", linkHandler.getUrl("1581461772"));
70+
assertEquals("https://shirakumon.bandcamp.com", linkHandler.getUrl("1581461772"));
7171
assertEquals("https://infiniteammo.bandcamp.com", linkHandler.getUrl("3321800855"));
7272

7373
assertEquals("https://lobstertheremin.com", linkHandler.getUrl("2735462545"));
@@ -82,5 +82,4 @@ public void testGetUrlWithInvalidId() {
8282
public void testGetIdWithInvalidUrl() {
8383
assertThrows(ParsingException.class, () -> linkHandler.getUrl("https://bandcamp.com"));
8484
}
85-
8685
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package org.schabi.newpipe.extractor.services.bandcamp;
2+
3+
import org.junit.jupiter.api.BeforeAll;
4+
import org.junit.jupiter.api.Test;
5+
import org.schabi.newpipe.downloader.DownloaderTestImpl;
6+
import org.schabi.newpipe.extractor.NewPipe;
7+
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
8+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
9+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
10+
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
11+
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelTabExtractor;
12+
13+
import java.io.IOException;
14+
15+
import static org.junit.jupiter.api.Assertions.assertEquals;
16+
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
17+
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
18+
19+
class BandcampChannelTabExtractorTest {
20+
21+
static class Tracks implements BaseListExtractorTest {
22+
private static BandcampChannelTabExtractor extractor;
23+
24+
@BeforeAll
25+
static void setUp() throws IOException, ExtractionException {
26+
NewPipe.init(DownloaderTestImpl.getInstance());
27+
extractor = (BandcampChannelTabExtractor) Bandcamp
28+
.getChannelTabExtractorFromId("2464198920", ChannelTabs.TRACKS);
29+
extractor.fetchPage();
30+
}
31+
32+
@Test
33+
@Override
34+
public void testServiceId() throws Exception {
35+
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
36+
}
37+
38+
@Test
39+
@Override
40+
public void testName() throws Exception {
41+
assertEquals(ChannelTabs.TRACKS, extractor.getName());
42+
}
43+
44+
@Test
45+
@Override
46+
public void testId() throws ParsingException {
47+
assertEquals("2464198920", extractor.getId());
48+
}
49+
50+
@Test
51+
@Override
52+
public void testUrl() throws ParsingException {
53+
assertEquals("https://wintergatan.bandcamp.com/track", extractor.getUrl());
54+
}
55+
56+
@Test
57+
@Override
58+
public void testOriginalUrl() throws Exception {
59+
assertEquals("https://wintergatan.bandcamp.com/track", extractor.getOriginalUrl());
60+
}
61+
62+
@Test
63+
@Override
64+
public void testRelatedItems() throws Exception {
65+
defaultTestRelatedItems(extractor);
66+
}
67+
68+
@Test
69+
@Override
70+
public void testMoreRelatedItems() throws Exception {
71+
// Bandcamp only return a single page
72+
}
73+
}
74+
75+
static class Albums implements BaseListExtractorTest {
76+
private static BandcampChannelTabExtractor extractor;
77+
78+
@BeforeAll
79+
static void setUp() throws IOException, ExtractionException {
80+
NewPipe.init(DownloaderTestImpl.getInstance());
81+
extractor = (BandcampChannelTabExtractor) Bandcamp
82+
.getChannelTabExtractorFromId("2450875064", ChannelTabs.ALBUMS);
83+
extractor.fetchPage();
84+
}
85+
86+
@Test
87+
@Override
88+
public void testServiceId() {
89+
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
90+
}
91+
92+
@Test
93+
@Override
94+
public void testName() throws Exception {
95+
assertEquals(ChannelTabs.ALBUMS, extractor.getName());
96+
}
97+
98+
@Test
99+
@Override
100+
public void testId() throws ParsingException {
101+
assertEquals("2450875064", extractor.getId());
102+
}
103+
104+
@Test
105+
@Override
106+
public void testUrl() throws ParsingException {
107+
assertEquals("https://toupie.bandcamp.com/album", extractor.getUrl());
108+
}
109+
110+
@Test
111+
@Override
112+
public void testOriginalUrl() throws Exception {
113+
assertEquals("https://toupie.bandcamp.com/album", extractor.getOriginalUrl());
114+
}
115+
116+
@Test
117+
@Override
118+
public void testRelatedItems() throws Exception {
119+
defaultTestRelatedItems(extractor);
120+
}
121+
122+
@Test
123+
@Override
124+
public void testMoreRelatedItems() throws Exception {
125+
// Bandcamp only return a single page
126+
}
127+
}
128+
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsLinkHandlerFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class BandcampCommentsLinkHandlerFactoryTest {
2020

2121
@BeforeAll
2222
public static void setUp() {
23-
linkHandler = new BandcampCommentsLinkHandlerFactory();
23+
linkHandler = BandcampCommentsLinkHandlerFactory.getInstance();
2424
NewPipe.init(DownloaderTestImpl.getInstance());
2525
}
2626

extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedLinkHandlerFactoryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class BandcampFeaturedLinkHandlerFactoryTest {
1818

1919
@BeforeAll
2020
public static void setUp() {
21-
linkHandler = new BandcampFeaturedLinkHandlerFactory();
21+
linkHandler = BandcampFeaturedLinkHandlerFactory.getInstance();
2222
}
2323

2424

@@ -42,7 +42,7 @@ public void testGetUrl() throws ParsingException {
4242
}
4343

4444
@Test
45-
public void testGetId() {
45+
public void testGetId() throws ParsingException {
4646
assertEquals("Featured", linkHandler.getId("http://bandcamp.com/api/mobile/24/bootstrap_data"));
4747
assertEquals("Featured", linkHandler.getId("https://bandcamp.com/api/mobile/24/bootstrap_data"));
4848
assertEquals("Radio", linkHandler.getId("http://bandcamp.com/?show=1"));

extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class BandcampPlaylistLinkHandlerFactoryTest {
2121

2222
@BeforeAll
2323
public static void setUp() {
24-
linkHandler = new BandcampPlaylistLinkHandlerFactory();
24+
linkHandler = BandcampPlaylistLinkHandlerFactory.getInstance();
2525
NewPipe.init(DownloaderTestImpl.getInstance());
2626
}
2727

extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public class BandcampStreamLinkHandlerFactoryTest {
2020

2121
@BeforeAll
2222
public static void setUp() {
23-
linkHandler = new BandcampStreamLinkHandlerFactory();
23+
linkHandler = BandcampStreamLinkHandlerFactory.getInstance();
2424
NewPipe.init(DownloaderTestImpl.getInstance());
2525
}
2626

2727
@Test
28-
public void testGetRadioUrl() {
28+
public void testGetRadioUrl() throws ParsingException {
2929
assertEquals("https://bandcamp.com/?show=1", linkHandler.getUrl("1"));
3030
}
3131

0 commit comments

Comments
 (0)