X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Frhynodge%2Ffilters%2Fwebpages%2Fsavoy%2FMovieStateTest.kt;h=77ff2d3e5c91f1eee9b2084b3ca5ce3ca9fe9459;hb=8aeef90590095a455e2323d70ba8ccae032f4276;hp=857bd0325f681b3fb2c5a7c3f07f0b444526ffd0;hpb=c01a15c35517e70e6cc8715d3e053095b8ae1f97;p=rhynodge.git diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt index 857bd03..77ff2d3 100644 --- a/src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt +++ b/src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt @@ -9,6 +9,7 @@ import org.hamcrest.Matchers.empty import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.not import org.jsoup.Jsoup +import org.jsoup.nodes.Element import org.jsoup.nodes.TextNode import org.junit.Test import java.time.LocalDateTime @@ -19,9 +20,9 @@ class MovieStateTest { fun `summary contains date of earliest movie`() { val movieState = MovieState( setOf( - Movie("1", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 2, 12, 18, 45), "", "")) }, - Movie("2", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 3, 12, 15, 30), "", "")) }, - Movie("3", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 2, 11, 21, 15), "", "")) } + Movie("1", "", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 2, 12, 18, 45), "", "")) }, + Movie("2", "", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 3, 12, 15, 30), "", "")) }, + Movie("3", "", "").apply { addPerformance(Performance(LocalDateTime.of(2024, 2, 11, 21, 15), "", "")) } ), emptySet() ) assertThat(movieState.output(Reaction("", null, null, null)).summary(), containsString("2024-02-11")) @@ -34,7 +35,7 @@ class MovieStateTest { @Test fun `movie state with a new movie is triggered`() { - assertThat(MovieState(emptySet(), setOf(Movie("1", ""))).triggered(), equalTo(true)) + assertThat(MovieState(emptySet(), setOf(Movie("1", "", ""))).triggered(), equalTo(true)) } @Test @@ -47,15 +48,23 @@ class MovieStateTest { @Test fun `html output does contain a section for new movie if there are new movies`() { - val movieState = MovieState(emptySet(), setOf(Movie("1", ""), Movie("2", ""))) + val movieState = MovieState(emptySet(), setOf(Movie("1", "", ""), Movie("2", "", ""))) val output = movieState.output(Reaction("", null, null, null)) val document = Jsoup.parse(output.text("text/html")) assertThat(document.select("section.new-movies"), not(empty())) } @Test + fun `new movies section contains description of movies`() { + val movieState = MovieState(emptySet(), setOf(Movie("1", "", "Movie 1 is cool."), Movie("2", "", "Movie 2 is bad."))) + val output = movieState.output(Reaction("", null, null, null)) + val document = Jsoup.parse(output.text("text/html")) + assertThat(document.select("section.new-movies .description").map(Element::text), contains("Movie 1 is cool.", "Movie 2 is bad.")) + } + + @Test fun `new movies section contains the titles of all new movies`() { - val movieState = MovieState(emptySet(), setOf(Movie("New Movie", ""), Movie("Even Newer Movie", ""))) + val movieState = MovieState(emptySet(), setOf(Movie("New Movie", "", ""), Movie("Even Newer Movie", "", ""))) val output = movieState.output(Reaction("", null, null, null)) val document = Jsoup.parse(output.text("text/html")) assertThat(document.select("section.new-movies li.movie .name").textNodes().map(TextNode::text), containsInAnyOrder("New Movie", "Even Newer Movie")) @@ -73,10 +82,10 @@ class MovieStateTest { fun `html output contains a section for each day with a movie`() { val movieState = MovieState( setOf( - movie("Movie 1", "", "20240212-1845", "20240213-1330", "20240214-1815"), - movie("Movie 2", "", "20240212-2030", "20240213-1745", "20240214-1430"), - movie("Movie 3", "", "20240213-2015", "20240214-1730"), - movie("Movie 4", "", "20240216-1000"), + movie("Movie 1", "", "", "20240212-1845", "20240213-1330", "20240214-1815"), + movie("Movie 2", "", "", "20240212-2030", "20240213-1745", "20240214-1430"), + movie("Movie 3", "", "", "20240213-2015", "20240214-1730"), + movie("Movie 4", "", "", "20240216-1000"), ), emptySet() ) val output = movieState.output(Reaction("", null, null, null)) @@ -89,13 +98,13 @@ class MovieStateTest { fun `html output contains the correct movies within each day`() { val movieState = MovieState( setOf( - movie("Movie 1", "https://cdn.premiumkino.de/movie/3047/81c49774d7828a898ae1d525ffd135af_w300.jpg", "20240212-1845", "20240213-1330", "20240214-1815"), - movie("Movie 2", "https://cdn.premiumkino.de/movie/1066/aba09af737677ff6a15676ae588098b1_w300.jpg", "20240212-2030", "20240213-1745", "20240214-1430"), - movie("Movie 3", "https://cdn.premiumkino.de/movie/7300/14d1b21dee51a82a7b096ca282bf01c8_w300.png", "20240213-2015", "20240214-1730"), - movie("Movie 4", "https://cdn.premiumkino.de/movie/6080/cef2b33483d2898ddb472c955c58ea20_w300.jpg", "20240216-1000"), + movie("Movie 1", "https://cdn.premiumkino.de/movie/3047/81c49774d7828a898ae1d525ffd135af_w300.jpg", "", "20240212-1845", "20240213-1330", "20240214-1815"), + movie("Movie 2", "https://cdn.premiumkino.de/movie/1066/aba09af737677ff6a15676ae588098b1_w300.jpg", "", "20240212-2030", "20240213-1745", "20240214-1430"), + movie("Movie 3", "https://cdn.premiumkino.de/movie/7300/14d1b21dee51a82a7b096ca282bf01c8_w300.png", "", "20240213-2015", "20240214-1730"), + movie("Movie 4", "https://cdn.premiumkino.de/movie/6080/cef2b33483d2898ddb472c955c58ea20_w300.jpg", "", "20240216-1000"), ), setOf( - movie("Movie 1", "https://cdn.premiumkino.de/movie/3047/81c49774d7828a898ae1d525ffd135af_w300.jpg", "20240212-1845", "20240213-1330", "20240214-1815"), - movie("Movie 2", "https://cdn.premiumkino.de/movie/1066/aba09af737677ff6a15676ae588098b1_w300.jpg", "20240212-1845", "20240213-1330", "20240214-1815") + movie("Movie 1", "https://cdn.premiumkino.de/movie/3047/81c49774d7828a898ae1d525ffd135af_w300.jpg", "", "20240212-1845", "20240213-1330", "20240214-1815"), + movie("Movie 2", "https://cdn.premiumkino.de/movie/1066/aba09af737677ff6a15676ae588098b1_w300.jpg", "", "20240212-1845", "20240213-1330", "20240214-1815") ) ) val output = movieState.output(Reaction("", null, null, null)) @@ -112,7 +121,7 @@ class MovieStateTest { fun `html output contains the correct release type for movies`() { val movieState = MovieState( setOf( - movie("Movie 1", "https://cdn.premiumkino.de/movie/3047/81c49774d7828a898ae1d525ffd135af_w300.jpg", "20240212-1845" to "2D OV", "20240213-1330" to "2D", "20240214-1815" to "2D OmeU"), + movie("Movie 1", "https://cdn.premiumkino.de/movie/3047/81c49774d7828a898ae1d525ffd135af_w300.jpg", "", "20240212-1845" to "2D OV", "20240213-1330" to "2D", "20240214-1815" to "2D OmeU"), ), setOf() ) val output = movieState.output(Reaction("", null, null, null)) @@ -136,10 +145,10 @@ private fun dateTime(dateTimeString: String) = LocalDateTime.of( dateTimeString.substring(11..12).toInt(), ) -private fun movie(name: String, imageUrl: String, vararg times: String) = Movie(name, imageUrl).apply { +private fun movie(name: String, imageUrl: String, description: String = "", vararg times: String) = Movie(name, imageUrl, description).apply { times.map(::dateTime).map { Performance(it, "", "https://link/$it") }.forEach(this::addPerformance) } -private fun movie(name: String, imageUrl: String, vararg timesAndTypes: Pair) = Movie(name, imageUrl).apply { +private fun movie(name: String, imageUrl: String, description: String = "", vararg timesAndTypes: Pair) = Movie(name, imageUrl, description).apply { timesAndTypes.map { Performance(it.first.let(::dateTime), it.second, "https://link/${it.first}") }.forEach(this::addPerformance) }