Skip to content

Commit

Permalink
Add tests to BooruRipper
Browse files Browse the repository at this point in the history
  • Loading branch information
IrvinLara9 committed Dec 20, 2021
1 parent 9496962 commit edc7fa4
Showing 1 changed file with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import com.rarchives.ripme.ripper.rippers.BooruRipper;
import org.junit.jupiter.api.Assertions;
Expand All @@ -10,14 +12,49 @@
public class BooruRipperTest extends RippersTest {
@Test
public void testRip() throws IOException {
BooruRipper ripper = new BooruRipper(new URL("http://xbooru.com/index.php?page=post&s=list&tags=furry"));
testRipper(ripper);
List<URL> passURLs = new ArrayList<>();
passURLs.add(new URL("https://xbooru.com/index.php?page=post&s=list&tags=furry"));
passURLs.add(new URL("https://gelbooru.com/index.php?page=post&s=list&tags=animal_ears"));

for (URL url : passURLs) {
BooruRipper ripper = new BooruRipper(url);
testRipper(ripper);
}
}

@Test
public void testGetGID() throws IOException {
URL url = new URL("http://xbooru.com/index.php?page=post&s=list&tags=furry");
BooruRipper ripper = new BooruRipper(url);
Assertions.assertEquals("furry", ripper.getGID(url));
URL xbooruUrl = new URL("https://xbooru.com/index.php?page=post&s=list&tags=furry");
URL gelbooruUrl = new URL("https://gelbooru.com/index.php?page=post&s=list&tags=animal_ears");

BooruRipper xbooruRipper = new BooruRipper(xbooruUrl);
BooruRipper gelbooruRipper = new BooruRipper(gelbooruUrl);

Assertions.assertEquals("furry", xbooruRipper.getGID(xbooruUrl));
Assertions.assertEquals("animal_ears", gelbooruRipper.getGID(gelbooruUrl));
}

@Test
public void testGetDomain() throws IOException {
URL xbooruUrl = new URL("https://xbooru.com/index.php?page=post&s=list&tags=furry");
URL gelbooruUrl = new URL("https://gelbooru.com/index.php?page=post&s=list&tags=animal_ears");

BooruRipper xbooruRipper = new BooruRipper(xbooruUrl);
BooruRipper gelbooruRipper = new BooruRipper(gelbooruUrl);

Assertions.assertEquals("xbooru.com", xbooruRipper.getDomain());
Assertions.assertEquals("gelbooru.com", gelbooruRipper.getDomain());
}

@Test
public void testGetHost() throws IOException {
URL xbooruUrl = new URL("https://xbooru.com/index.php?page=post&s=list&tags=furry");
URL gelbooruUrl = new URL("https://gelbooru.com/index.php?page=post&s=list&tags=animal_ears");

BooruRipper xbooruRipper = new BooruRipper(xbooruUrl);
BooruRipper gelbooruRipper = new BooruRipper(gelbooruUrl);

Assertions.assertEquals("xbooru", xbooruRipper.getHost());
Assertions.assertEquals("gelbooru", gelbooruRipper.getHost());
}
}

0 comments on commit edc7fa4

Please sign in to comment.