0.86.0: Orbit 1 and Orbit 2 identities, with blocks, Friday Spooky Teatime, mixed sitcoms and quizzes, and supporting titles
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m55s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m25s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-03 12:47:18 +00:00
co-authored by Claude Opus 5.5
parent 9f3077c84c
commit fc2b8f18d3
10 changed files with 140 additions and 17 deletions
@@ -0,0 +1,71 @@
package tv.orbit.classic
import org.junit.Assert.*
import org.junit.Test
import java.time.ZoneId
import java.time.ZonedDateTime
/** A week of Orbit 1 and Orbit 2 from stand-in libraries, checked block by block. */
class ChannelIdentityTest {
private val zone = ZoneId.of("Europe/London")
private val monday = ZonedDateTime.of(2026, 11, 9, 0, 0, 0, 0, zone).toInstant().toEpochMilli()
private val week = 7 * 24 * 60 * 60_000L
private fun library(titles: List<String>, minutes: Long) = titles.mapIndexed { i, title ->
PoolSeries("s$i", title, (1..30).map { PoolEpisode("s$i-$it", "src", EpisodeMark(1, it), "E$it", (minutes + it % 3) * 60_000L) })
}
private fun plan(number: Int, minutes: Long): ChannelPlan {
val programming = SmartChannels.first { it.number == number }
return extendSchedule(library(programming.searches, minutes), ScheduleCursor(), monday, monday + week, finishTogether = programming.finishTogether,
dayParts = programming.dayParts, zone = zone, mixed = programming::mixes)
}
private fun local(ms: Long) = java.time.Instant.ofEpochMilli(ms).atZone(zone)
private fun titlesWhere(plan: ChannelPlan, test: (ZonedDateTime) -> Boolean) = plan.entries.filter { test(local(it.startMs)) }.map { it.media.item.title.substringBefore(" / ") }.toSet()
private fun keys(vararg titles: String) = titles.map(::seriesKey).toSet()
@Test fun orbit1KeepsItsBlocks() {
val plan = plan(101, 23)
val sundayDrama = titlesWhere(plan) { it.dayOfWeek == java.time.DayOfWeek.SUNDAY && it.hour in 18..19 }
assertTrue(sundayDrama.isNotEmpty() && sundayDrama.map(::seriesKey).all { it in keys("Doc Martin", "Heartbeat", "Ballykissangel", "Little House on the Prairie", "The Waltons") })
val weekend = titlesWhere(plan) { it.dayOfWeek.value >= 6 && it.hour in 6..17 }
assertTrue("Saturday and Sunday daytime is British", weekend.all { seriesKey(it) in keys("My Family", "Outnumbered", "Not Going Out", "Miranda", "Last of the Summer Wine", "Bread",
"Goodnight Sweetheart", "Mrs. Brown's Boys", "Red Dwarf", "The Royle Family", "My Hero", "dinnerladies") })
assertTrue("Weekday daytime is family", titlesWhere(plan) { it.dayOfWeek.value <= 5 && it.hour in 6..17 }.contains("Saved by the Bell"))
assertFalse("Frasier is an evening show", titlesWhere(plan) { it.dayOfWeek.value <= 5 && it.hour in 6..17 }.contains("Frasier"))
assertTrue(titlesWhere(plan) { it.hour >= 18 }.contains("Frasier"))
}
@Test fun orbit1StoriesStayInOrderAndSitcomsMix() {
val plan = plan(101, 23)
val wonder = plan.entries.filter { it.media.item.title.startsWith("The Wonder Years") }.map { it.mark.episode }
assertEquals(wonder.sorted(), wonder)
val fresh = plan.entries.filter { it.media.item.title.startsWith("The Fresh Prince") }.map { it.mark.episode }
assertNotEquals(fresh.sorted(), fresh)
}
@Test fun orbit2FridaySpookyFitsCleanly() {
val plan = plan(102, 22)
val friday = titlesWhere(plan) { it.dayOfWeek == java.time.DayOfWeek.FRIDAY && it.hour in 17..18 }
assertEquals(keys("Goosebumps", "Are You Afraid of the Dark?", "Eerie, Indiana"), friday.map(::seriesKey).toSet())
// Teatime still runs before it, and game shows after it.
assertTrue(titlesWhere(plan) { it.dayOfWeek == java.time.DayOfWeek.FRIDAY && it.hour == 16 }.all { it !in setOf("Goosebumps", "Are You Afraid of the Dark?", "Eerie, Indiana") })
assertTrue(titlesWhere(plan) { it.dayOfWeek == java.time.DayOfWeek.FRIDAY && it.hour == 19 }.any { it in setOf("The Crystal Maze", "Gladiators", "Robot Wars", "Takeshi's Castle", "Fort Boyard (UK)", "Total Wipeout", "Knightmare", "GamesMaster") })
// Spooky shows only on Friday teatime.
assertTrue(titlesWhere(plan) { !(it.dayOfWeek == java.time.DayOfWeek.FRIDAY && it.hour in 17..18) }.none { it in setOf("Goosebumps", "Are You Afraid of the Dark?", "Eerie, Indiana") })
}
@Test fun orbit2RetroActionOwnsTheNight() {
val plan = plan(102, 45)
val night = titlesWhere(plan) { it.hour in 0..5 }
assertTrue(night.containsAll(setOf("Knight Rider", "The A-Team", "Airwolf", "MacGyver")))
assertTrue(titlesWhere(plan) { it.hour in 15..17 && it.dayOfWeek != java.time.DayOfWeek.FRIDAY }.contains("Countdown"))
}
@Test fun bothChannelsRunBackToBackWithoutLongRuns() {
for (number in listOf(101, 102)) {
val plan = plan(number, 25)
assertTrue(plan.entries.zipWithNext().all { (a, b) -> a.endMs == b.startMs })
val longest = plan.entries.fold(Triple("", 0, 0)) { (p, r, best), e -> val n = if (e.seriesId == p) r + 1 else 1; Triple(e.seriesId, n, maxOf(best, n)) }.third
assertTrue("channel $number longest run $longest", longest <= 2)
}
}
}