You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
9.8 KiB
Kotlin

package moe.odango.index.test.scraper.mal
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import moe.odango.index.entity.AnimeRelation
import moe.odango.index.entity.MyAnimeListInfo
import moe.odango.index.scraper.mal.AnimePageScraper
import moe.odango.index.scraper.mal.AnimePageScraper.Genre
import moe.odango.index.utils.IntDate
import moe.odango.index.utils.ProducerFunction
import java.time.Duration
class AnimePageScraperTest : StringSpec({
"test-bodyscraper" {
val body = this::class.java.getResourceAsStream("/test-pages/25313.html")
.readAllBytes()
.toString(Charsets.UTF_8)
val scraper = AnimePageScraper(body)
scraper.getDescription().trim() shouldBe """
Bundled with limited edition of the 58th Gintama manga volume.
The tagline for the bundled anime reads, "It's time for all the Yorozuya members ...to wake up just one more time."
(Source: MAL News, edited)
""".trim()
scraper.getImage() shouldBe "https://cdn.myanimelist.net/images/anime/12/64865.jpg"
val related = scraper.getRelated()
related shouldHaveSize 1
related[0].id shouldBe 15417L
related[0].type shouldBe AnimeRelation.RelationType.ParentStory
scraper.getPremiered() shouldBe null
scraper.getAired() shouldNotBe null
scraper.getAired()?.start shouldBe IntDate(2015, 3, 3)
scraper.getSource() shouldBe "Manga"
scraper.getDuration() shouldBe Duration.ofMinutes(24)
scraper.getRating() shouldBe MyAnimeListInfo.Rating.PG13
}
val items = mapOf(
"616.html" to AnimePageScraper.Info(
"Nurse Angel Ririka SOS",
null,
"ナースエンジェルりりかSOS",
listOf(),
"""
The Evil Forces of Dark Joker are closing in on our planet after having destroyed the beautiful planet of Queen Earth. Now, 10 year old Moriya Ririka, with the help of her childhood friend Seiya and the mysterious Kanon, must transform into the Nurse Angel and find the elusive Flower of Life, the only way to defeat the evil forces. The Flower of Life, that once bloomed all over the Earth, is where no one thought it ever would be. And Ririka must make the hardest decision of her life in order to acquire it and rid the universe of evil once and for all.
(Source: ANN)
""".trimIndent(),
MyAnimeListInfo.ReleaseType.TV,
35,
"Manga",
"https://cdn.myanimelist.net/images/anime/10/10506.jpg",
listOf(
Genre.DRAMA,
Genre.FANTASY,
Genre.MAGIC,
Genre.SHOUJO
),
AnimePageScraper.Aired(
IntDate(1995, 6, 7),
IntDate(1996, 2, 29)
),
AnimePageScraper.Premiered(AnimePageScraper.Premiered.Season.Summer, 1995),
MyAnimeListInfo.Rating.PG,
Duration.ofMinutes(24),
listOf(),
listOf(
AnimePageScraper.ProducerRelation(ProducerFunction.Producer, AnimePageScraper.Producer(16, "TV Tokyo")),
AnimePageScraper.ProducerRelation(
ProducerFunction.Producer,
AnimePageScraper.Producer(139, "Nihon Ad Systems")
),
AnimePageScraper.ProducerRelation(ProducerFunction.Studio, AnimePageScraper.Producer(36, "Gallop"))
)
),
"817.html" to AnimePageScraper.Info(
"Tactical Roar",
null,
"タクティカルロア",
listOf("Tactical Rawr"),
"""
In the near future the world's climate shifted creating in the Western Pacific a perpetual super cyclone: the Grand Roar that altered the earth, flooding most countries. Shipping and navigation became important to nations and following the appearance of ocean pirates, necessisated companies to hire escort cruisers to safeguard their investments. Hyousuke Nagimiya is a system engineer that was comissioned to upgrade the Pascal Magi manned by an entire crew of women with its captain, Misaki Nanaha. Together the crew strives to prove themselves to their detractors that they are no mere 'Alice Brand'. Yet as they go about their mission a larger global conspiracy seems to be working behind the scenes to take advantage of this new world order.
(Source: ANN)
""".trimIndent(),
MyAnimeListInfo.ReleaseType.TV,
13,
"Unknown",
"https://cdn.myanimelist.net/images/anime/8/61829.jpg",
listOf(
Genre.COMEDY,
Genre.MILITARY,
Genre.ROMANCE,
Genre.SCIFI
),
AnimePageScraper.Aired(
IntDate(2006, 0, 8),
IntDate(2006, 3, 2)
),
AnimePageScraper.Premiered(AnimePageScraper.Premiered.Season.Winter, 2006),
MyAnimeListInfo.Rating.PG13,
Duration.ofMinutes(25),
listOf(
AnimePageScraper.Relation(AnimeRelation.RelationType.SideStory, 1790)
),
listOf(
AnimePageScraper.ProducerRelation(ProducerFunction.Producer, AnimePageScraper.Producer(23, "Bandai Visual")),
AnimePageScraper.ProducerRelation(ProducerFunction.Producer, AnimePageScraper.Producer(104, "Lantis")),
AnimePageScraper.ProducerRelation(ProducerFunction.Studio, AnimePageScraper.Producer(60, "Actas"))
)
),
"1558.html" to AnimePageScraper.Info(
"Yarima Queen",
"Sex Demon Queen",
"ヤーリマクィーン",
listOf(),
"""
The sorceress Kuri uses her magic to defend herself from perverted monsters and demons, but her partner, Rima, would much rather do perverted things than defend herself. When the two save a woman from a gang rape, they catch the eye of an evil Sex Queen and her dog-demons. When the sex demons release the passions of Kuri and Rima, even the duo`s formidable powers will be useless. Don`t miss it as all four girls redefine the meaning of Doggie Style!
(Source: AniDB)
""".trimIndent(),
MyAnimeListInfo.ReleaseType.OVA,
1,
"Unknown",
"https://cdn.myanimelist.net/images/anime/10/41571.jpg",
listOf(
Genre.COMEDY,
Genre.DEMONS,
Genre.FANTASY,
Genre.HENTAI,
Genre.MAGIC,
Genre.PARODY
),
AnimePageScraper.Aired(
IntDate(2000, 5, 25)
),
null,
MyAnimeListInfo.Rating.Rx,
Duration.ofMinutes(30),
listOf(),
listOf(
AnimePageScraper.ProducerRelation(ProducerFunction.Producer, AnimePageScraper.Producer(48, "AIC")),
AnimePageScraper.ProducerRelation(ProducerFunction.Producer, AnimePageScraper.Producer(152, "Green Bunny")),
AnimePageScraper.ProducerRelation(ProducerFunction.Licensor, AnimePageScraper.Producer(250, "Media Blasters")),
AnimePageScraper.ProducerRelation(ProducerFunction.Licensor, AnimePageScraper.Producer(595, "NYAV Post"))
)
),
"1581.html" to AnimePageScraper.Info(
"Gift: Eternal Rainbow",
null,
"ギフト~ eternal rainbow",
listOf(),
"""
Amaumi Haruhiko is a high school student who attends Shimano Academy in a town called Narasakicho. Narasakicho contains an unknown rainbow which constantly overlooks the town and is related to granting a magical wish called "Gift." Gift is a once-in-a-lifetime present between two people.
As a child, Haruhiko has been close with his childhood friend, Kirino, until he obtains a new non-blood sister by the name of Riko. Haruhiko develops a strong relationship with Riko until they sadly depart due to the fact Haruhiko's father could no longer support the two of them.
After some times passes by, Riko finally returns to the town of Narasakicho, and along with Kirino, starts to attend Shimano Academy with Haruhiko. The series revolves around the relationship among these main protagonists and slowly reveals the story behind both Gift and the rainbow.
""".trimIndent(),
MyAnimeListInfo.ReleaseType.TV,
12,
"Visual novel",
"https://cdn.myanimelist.net/images/anime/2/75540.jpg",
listOf(
Genre.COMEDY,
Genre.DRAMA,
Genre.HAREM,
Genre.MAGIC,
Genre.ROMANCE,
Genre.SCHOOL
),
AnimePageScraper.Aired(
IntDate(2006, 9, 6),
IntDate(2006, 11, 22)
),
AnimePageScraper.Premiered(AnimePageScraper.Premiered.Season.Fall, 2006),
MyAnimeListInfo.Rating.PG13,
Duration.ofMinutes(24),
listOf(
AnimePageScraper.Relation(AnimeRelation.RelationType.SideStory, 2784)
),
listOf(
AnimePageScraper.ProducerRelation(ProducerFunction.Producer, AnimePageScraper.Producer(829, "Studio Jack")),
AnimePageScraper.ProducerRelation(ProducerFunction.Studio, AnimePageScraper.Producer(28, "OLM"))
)
)
)
for ((file, info) in items) {
"Test $file" {
val html = this::class.java.getResourceAsStream("/test-pages/$file")
.readAllBytes()
.toString(Charsets.UTF_8)
AnimePageScraper(html)
.getInfo() shouldBe info
}
}
})