Add weekday events and a Vortex Movie Night (0.48.0 in testing)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -83,14 +83,14 @@ class ChannelSuggestionsTest {
|
||||
|
||||
@Test fun afterDarkAndVortexBlocksAcceptTheirGroups() {
|
||||
assertEquals("day", SmartChannels.first { it.number == 102 }.dayParts[1].group)
|
||||
assertEquals(listOf("day", "night"), SmartChannels.first { it.number == 103 }.dayParts.map { it.group })
|
||||
assertEquals(listOf("movie", "day", "night"), SmartChannels.first { it.number == 103 }.dayParts.map { it.group })
|
||||
}
|
||||
|
||||
@Test fun vortexKeepsPaulsToonamiPicksInTheRightBlocks() {
|
||||
val vortex = SmartChannels.first { it.number == 103 }
|
||||
val day = vortex.dayParts[0].titles.map(::seriesKey)
|
||||
val day = vortex.dayParts.first { it.group == "day" }.titles.map(::seriesKey)
|
||||
assertTrue(listOf("Batman Beyond", "Batman: The Animated Series", "ThunderCats", "The Powerpuff Girls", "Jonny Quest").all { seriesKey(it) in day })
|
||||
assertTrue(seriesKey("Dragon Ball Z") in vortex.dayParts[1].titles.map(::seriesKey))
|
||||
assertTrue(seriesKey("Dragon Ball Z") in vortex.dayParts.first { it.group == "night" }.titles.map(::seriesKey))
|
||||
assertEquals(vortex.searches.size, vortex.searches.distinct().size)
|
||||
assertTrue(vortex.seriesCount >= vortex.searches.size)
|
||||
}
|
||||
@@ -114,4 +114,58 @@ class ChannelSuggestionsTest {
|
||||
@Test fun vortexOnlyTakesExactTitles() {
|
||||
assertTrue(SmartChannels.first { it.number == 103 }.exactTitles)
|
||||
}
|
||||
|
||||
private val london = java.time.ZoneId.of("Europe/London")
|
||||
private fun at(d: Int, h: Int, m: Int = 0) = java.time.ZonedDateTime.of(2026, 11, d, h, m, 0, 0, london).toInstant().toEpochMilli()
|
||||
private fun show(id: String, group: String, n: Int = 200) = PoolSeries(id, id, (1..n).map { PoolEpisode("$id-$it", "s", EpisodeMark(1, it), "E$it", 24 * 60_000L) }, group)
|
||||
private fun film(id: String) = PoolSeries(id, id, listOf(PoolEpisode(id, "s$id", EpisodeMark(1, 1), id, 50 * 60_000L)), "movie")
|
||||
private val parts = listOf(DayPart(20, 22, group = "movie", days = setOf(java.time.DayOfWeek.FRIDAY)), DayPart(6, 18, group = "day"), DayPart(18, 6, group = "night"))
|
||||
private val vortexPool = listOf(show("c", "day"), show("a", "night"), film("m1"), film("m2"), film("m3"))
|
||||
private fun hour(ms: Long) = java.time.Instant.ofEpochMilli(ms).atZone(london)
|
||||
|
||||
@Test fun moviesOnlyAirOnMovieNight() {
|
||||
val start = at(2, 7) // Monday
|
||||
val entries = extendSchedule(vortexPool, ScheduleCursor(), start, start + 7 * 24 * 3_600_000L, finishTogether = true, dayParts = parts, zone = london).entries
|
||||
val films = entries.filter { it.media.item.type == "Movie" }
|
||||
assertTrue(films.isNotEmpty())
|
||||
films.forEach { assertEquals(java.time.DayOfWeek.FRIDAY, hour(it.startMs).dayOfWeek); assertTrue(hour(it.startMs).hour in 20 until 22) }
|
||||
assertTrue(films.all { !it.media.item.title.contains(" / ") })
|
||||
}
|
||||
|
||||
@Test fun movieNightReplacesTheEveningBlockThenItComesBack() {
|
||||
val friday = at(6, 19)
|
||||
val entries = extendSchedule(vortexPool, ScheduleCursor(), friday, friday + 5 * 3_600_000L, finishTogether = true, dayParts = parts, zone = london).entries
|
||||
assertEquals("a", entries.first().seriesId)
|
||||
assertTrue(entries.any { it.media.item.type == "Movie" })
|
||||
assertEquals("a", entries.last().seriesId)
|
||||
}
|
||||
|
||||
@Test fun moviesTakeTurnsBeforeRepeating() {
|
||||
val start = at(2, 7)
|
||||
val films = extendSchedule(vortexPool, ScheduleCursor(), start, start + 21 * 24 * 3_600_000L, finishTogether = true, dayParts = parts, zone = london).entries.filter { it.media.item.type == "Movie" }.map { it.seriesId }
|
||||
assertEquals(films.take(3).toSet().size, 3)
|
||||
}
|
||||
|
||||
@Test fun withNoMoviesThatNightRunsAsUsual() {
|
||||
val pool = listOf(show("c", "day"), show("a", "night"))
|
||||
assertEquals(listOf("a"), dayPartPool(pool, parts, at(6, 20, 30), london).map { it.id })
|
||||
}
|
||||
|
||||
@Test fun moviesStayOutOfEverydayBlocksEvenWithNoBlockForThem() {
|
||||
assertEquals(listOf("c"), dayPartPool(listOf(show("c", "day"), film("m1")), listOf(DayPart(0, 1, group = "x")), at(2, 12), london).map { it.id })
|
||||
}
|
||||
|
||||
@Test fun aFilmChannelStillUsesItsFilmsOutsideItsBlocks() {
|
||||
val films = listOf(film("a"), film("b"))
|
||||
assertEquals(2, dayPartPool(films, listOf(DayPart(0, 1, group = "x")), at(2, 12), london).size)
|
||||
}
|
||||
|
||||
@Test fun aRuleCanRequireWordsInTheTitle() {
|
||||
val named = rule.copy(genres = listOf("Animation"), titleContains = "Dragon Ball", minMinutes = 30)
|
||||
val requests = mutableListOf<EmbyRequest>()
|
||||
val rows = JSONArray().put(row("db", "Dragon Ball Z: Bardock", listOf("Animation"))).put(row("x", "Other Film", listOf("Animation")))
|
||||
val read = findSuggestions(EmbyTransport { requests += it; EmbyReply(200, JSONObject().put("Items", rows).toString()) }, user, { "t" }, listOf(named), emptySet(), emptySet())
|
||||
assertEquals(listOf("db"), read.suggestions.map { it.id })
|
||||
assertTrue(requests.single().path.contains("SearchTerm=Dragon+Ball"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user