Stop a show airing on two channels at once; add ToonZ, Rewind and Orbit X (0.50.0 in testing)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m47s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m28s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-02 09:03:32 +00:00
co-authored by Claude Opus 5.5
parent 1a5b6d67f2
commit 351ba4549c
20 changed files with 112 additions and 23 deletions
@@ -106,7 +106,7 @@ class ChannelPresetsTest {
}
@Test fun theNewChannelsAreConfiguredAndBranded() {
listOf(111, 121, 141).forEach { number ->
listOf(111, 121, 122, 123, 124, 141).forEach { number ->
assertTrue(SmartChannels.any { it.number == number && it.exactTitles && it.finishTogether })
assertNotNull(ChannelBrands.forNumber(number))
assertTrue(ChannelPresets.first { it.number == number }.smartOnly)
@@ -405,4 +405,49 @@ class ChannelScheduleTest {
dayParts = listOf(DayPart(6, 18, listOf("Show s")), DayPart(18, 6, listOf("Show o"))), zone = london).entries
assertEquals(List(6) { "s" }, entries.filter { localHour(it.startMs) in 6 until 18 }.map { it.seriesId })
}
private fun programmeOverlaps(a: List<ScheduleEntry>, b: List<ScheduleEntry>) = a.sumOf { x -> b.count { y ->
x.media.item.title.substringBefore(" / ") == y.media.item.title.substringBefore(" / ") && x.startMs < y.endMs && y.startMs < x.endMs } }
@Test fun aSharedShowNeverAirsOnTwoChannelsAtOnce() {
val shared = listOf(show("batman", 9, 40), show("spider", 9, 40), show("xmen", 9, 40))
val first = topUpPlan(null, ScheduleCursor(), shared, now)!!
val second = topUpPlan(null, ScheduleCursor(), shared, now, avoid = clashesWith(listOf(first)))!!
assertEquals(0, programmeOverlaps(first.entries, second.entries))
assertTrue(second.entries.map { it.seriesId }.toSet().size == 3)
}
@Test fun withoutTheRuleTheSamePoolWouldClash() {
val shared = listOf(show("batman", 9, 40), show("spider", 9, 40))
val first = topUpPlan(null, ScheduleCursor(), shared, now)!!
assertTrue(programmeOverlaps(first.entries, topUpPlan(null, ScheduleCursor(), shared, now)!!.entries) > 0)
}
@Test fun aChannelWithOnlyAClashingShowStillStaysOnAir() {
val only = listOf(show("batman", 9, 40))
val other = topUpPlan(null, ScheduleCursor(), only, now)!!
val plan = topUpPlan(null, ScheduleCursor(), only, now, avoid = clashesWith(listOf(other)))!!
assertEquals(other.entries.size, plan.entries.size)
}
@Test fun twoCopiesOfAShowCountAsTheSameShow() {
val copyA = PoolSeries("copy-a", "Dragon Ball Z", listOf(PoolEpisode("a1", "s", EpisodeMark(1, 1), "E", 30 * minute)))
val copyB = PoolSeries("copy-b", "The Dragon Ball Z", listOf(PoolEpisode("b1", "s", EpisodeMark(1, 1), "E", 30 * minute)))
val plan = extendSchedule(listOf(copyA), ScheduleCursor(), now, now + 30 * minute)
assertTrue(clashesWith(listOf(plan))(copyB, now + 10 * minute, now + 20 * minute))
assertFalse(clashesWith(listOf(plan))(copyB, now + 30 * minute, now + 60 * minute))
}
@Test fun filmsAvoidClashesToo() {
val other = extendSchedule(films, ScheduleCursor(), now, now + 7 * day, rest)
val mine = extendSchedule(films, ScheduleCursor(), now, now + 7 * day, rest, avoid = clashesWith(listOf(other)))
assertEquals(0, programmeOverlaps(other.entries, mine.entries))
}
@Test fun aFreshPlanDoesNotReadOtherChannels() {
var asked = false
val first = topUpPlan(null, ScheduleCursor(), pool, now)!!
topUpPlan(first, ScheduleCursor(), pool, now + minute, avoid = { _, _, _ -> asked = true; false })
assertFalse(asked)
}
}