From 95e2179643e335a51731c1f3e2c05174f79cf3de Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 20 Sep 2020 13:22:36 +0200 Subject: [PATCH] =?utf8?q?=E2=9C=85=20Add=20test=20for=20QC=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../comics/QuestionableContentFilterTest.kt | 29 ++ .../filters/comics/questionable-content.html | 375 +++++++++++++++++++++ 2 files changed, 404 insertions(+) create mode 100644 src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/QuestionableContentFilterTest.kt create mode 100644 src/test/resources/net/pterodactylus/rhynodge/filters/comics/questionable-content.html diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/QuestionableContentFilterTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/QuestionableContentFilterTest.kt new file mode 100644 index 0000000..39ae500 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/QuestionableContentFilterTest.kt @@ -0,0 +1,29 @@ +package net.pterodactylus.rhynodge.filters.comics + +import net.pterodactylus.rhynodge.filters.ResourceLoader +import net.pterodactylus.rhynodge.states.ComicState +import net.pterodactylus.rhynodge.states.ComicState.Comic +import net.pterodactylus.rhynodge.states.ComicState.Strip +import net.pterodactylus.rhynodge.states.HtmlState +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.contains +import org.junit.Test + +class QuestionableContentFilterTest { + + private val filter = QuestionableContentComicFilter() + private val htmlState: HtmlState = ResourceLoader + .loadDocument(javaClass, "questionable-content.html", baseUrl) + .let { HtmlState(baseUrl, it) } + + @Test + fun `comic is extracted correctly`() { + val comicState = filter.filter(htmlState) as ComicState + assertThat(comicState.comics(), contains( + Comic("").add(Strip("https://www.questionablecontent.net/comics/4355.png", "")) + )) + } + +} + +private const val baseUrl = "https://www.questionablecontent.net/" diff --git a/src/test/resources/net/pterodactylus/rhynodge/filters/comics/questionable-content.html b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/questionable-content.html new file mode 100644 index 0000000..073015e --- /dev/null +++ b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/questionable-content.html @@ -0,0 +1,375 @@ + + + + + + + + + + + + + Questionable Content + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
Menu
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ + + + + + + +
+
+ +
+
+ +
+ + + +
+
+ + + + + + + + + + + +
+ + + + + +
+ +
+
+ September 17, 2020 9:06pm +
+
+ + + +
+
+
+ +
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+ +
+
Other Good Comics:
+
+ +
+ + • Dave Willis Eats Diapers + + • Diesel Sweeties + + • Doodle For Food + + • Gunnerkrigg Court + + • Johnny Wander + + • Junior Scientist Power Hour + + • Qwantz + + • Sam & Fuzzy + + • Scenes From A Multiverse + + • Something Positive + + • Wasted Talent + + • Wondermark + + • XKCD + + +
+
+ +
+ + Alice Grove • Jeph's music on Bandcamp • QC Forums • Make a donation + • Privacy Policy + + • dord + + • urls +
+ + +
+ + + + +
+ + + +
+ +
+ +
+ +
+ +
+ + + +
+ +
+ + + + + +
+ + + + + + + + + + + + +

+

+ + + +

+ +
+
+ + + +
+ + + + + + + + + + + + + -- 2.7.4