0.81.0: Orbit Tots, with shuffled episodes, day-part idents and Wind Down Now
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m58s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m35s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-03 00:32:01 +00:00
co-authored by Claude Opus 5.5
parent ef41d04dec
commit a5ea55e1e2
34 changed files with 663 additions and 31 deletions
@@ -163,7 +163,7 @@ class ChannelPresetsTest {
}
listOf(612, 613, 306, 303, 304, 302, 307, 301).forEach { assertNotNull(SmartChannels.first { channel -> channel.number == it }.filmRestMs) }
assertEquals(ChannelCategory.Sport, ChannelBrands.forNumber(401)!!.category)
assertEquals(29, SmartChannels.size)
assertEquals(30, SmartChannels.size)
}
@Test fun ringXKeepsItsWeeknightsAndFallsBackToTheVault() {
@@ -194,7 +194,7 @@ class ChannelPresetsTest {
@Test fun everySmartChannelIsBrandedAndNumberedAfterTheMove() {
SmartChannels.forEach { assertNotNull("${it.name} has no brand at ${it.number}", ChannelBrands.forNumber(it.number)) }
assertEquals(OldChannelNumbers.values.toSet() - DRIVE_IN_NUMBER + 101, SmartChannels.map { it.number }.toSet())
assertEquals(OldChannelNumbers.values.toSet() - DRIVE_IN_NUMBER + 101 + TOTS_NUMBER, SmartChannels.map { it.number }.toSet())
}
@Test fun channelsSitInTheirBlocks() {
@@ -0,0 +1,93 @@
package tv.orbit.classic
import org.junit.Assert.*
import org.junit.Test
import java.time.ZoneId
import java.time.ZonedDateTime
class TotsTest {
private val zone = ZoneId.of("Europe/London")
private fun at(hour: Int, day: Int = 3) = ZonedDateTime.of(2026, 11, day, hour, 0, 0, 0, zone).toInstant().toEpochMilli()
private fun show(title: String, count: Int) = PoolSeries(title, title, (1..count).map { PoolEpisode("$title$it", "s", EpisodeMark(1, it), "E$it", 10 * 60_000L) })
@Test fun moodFollowsLocalHours() {
assertEquals(TotsMood.Night, totsMood(at(5), zone))
assertEquals(TotsMood.Morning, totsMood(at(6), zone))
assertEquals(TotsMood.Playtime, totsMood(at(9), zone))
assertEquals(TotsMood.WindDown, totsMood(at(17), zone))
assertEquals(TotsMood.Night, totsMood(at(21), zone))
}
@Test fun moodMovesWithTheClocks() {
// 06:00 British Summer Time on the last Saturday of October, an hour earlier by the universal clock than in winter.
val summer = ZonedDateTime.of(2026, 10, 24, 6, 0, 0, 0, zone).toInstant().toEpochMilli()
assertEquals(TotsMood.Morning, totsMood(summer, zone))
}
@Test fun onlyTheTwoMoodsSing() {
assertFalse(TotsJingle.take(TotsMood.Playtime, 1_000_000_000L))
assertFalse(TotsJingle.take(TotsMood.Night, 1_000_000_000L))
}
@Test fun jingleWaitsThirtyMinutes() {
val start = 2_000_000_000_000L
assertTrue(TotsJingle.take(TotsMood.Morning, start))
assertFalse(TotsJingle.take(TotsMood.Morning, start + 29 * 60_000L))
assertTrue(TotsJingle.take(TotsMood.WindDown, start + 30 * 60_000L))
}
@Test fun identFollowsTheNextProgramme() {
assertEquals(TotsMood.Morning.video, identVideo(TOTS_NUMBER, at(7)))
assertEquals(5_000L, identLength(TOTS_NUMBER, at(7)))
assertEquals(6_000L, identLength(TOTS_NUMBER, at(18)))
}
@Test fun everyEpisodePlaysOnceBeforeAnyRepeat() {
val pool = listOf(show("a", 12), show("b", 12))
val plan = extendSchedule(pool, ScheduleCursor(), at(10), at(10) + 24 * 10 * 60_000L, finishTogether = true, zone = zone, shuffle = true)
assertEquals(24, plan.entries.size)
assertEquals(24, plan.entries.map { it.media.item.id }.distinct().size)
}
@Test fun shuffleIsMixedAndRepeatable() {
val series = show("a", 40)
assertEquals(shuffledEpisodes(series), shuffledEpisodes(series))
assertNotEquals(series.episodes, shuffledEpisodes(series))
}
@Test fun shuffleCarriesOnFromItsPlace() {
val pool = listOf(show("a", 6))
val first = extendSchedule(pool, ScheduleCursor(), at(10), at(10) + 30 * 60_000L, zone = zone, shuffle = true)
val rest = extendSchedule(pool, first.tail, first.endMs, first.endMs + 30 * 60_000L, zone = zone, shuffle = true)
assertEquals(6, (first.entries + rest.entries).map { it.media.item.id }.distinct().size)
}
@Test fun otherChannelsStayInSeasonOrder() {
val plan = extendSchedule(listOf(show("a", 5)), ScheduleCursor(), at(10), at(10) + 50 * 60_000L, zone = zone)
assertEquals((1..5).toList(), plan.entries.map { it.mark.episode })
}
@Test fun windDownEndsAtTheNextMorning() {
assertEquals(at(6, 4), totsWindDownEnd(at(10), zone))
assertEquals(at(6, 4), totsWindDownEnd(at(20), zone))
assertEquals(at(6), totsWindDownEnd(at(2), zone))
}
@Test fun eveningOnlyOffersCalmShows() {
val calm = TotsWindDown.map(::seriesKey).toSet()
TotsDayParts.filter { it.covers(18) || it.covers(23) }.forEach { part -> assertEquals(calm, part.titles.map(::seriesKey).toSet()) }
}
@Test fun stepInCoversThePlanThenHandsBack() {
val pool = listOf(show("a", 50))
val main = extendSchedule(pool, ScheduleCursor(), at(10), at(14), zone = zone)
val channel = ScheduledChannel(SampleChannel(main.entries.take(2).map { it.media }, "t", TOTS_NUMBER), main)
val calm = listOf(show("calm", 5))
channel.stepIn = extendSchedule(calm, ScheduleCursor(), at(11), at(11) + 50 * 60_000L, zone = zone)
assertEquals("calm1", channel.at(at(11) + 1).media.item.id)
assertTrue(channel.at(at(13)).media.item.id.startsWith("a"))
assertEquals(main.entries.size, channel.plan.entries.size)
channel.stepIn = null
assertTrue(channel.at(at(11) + 1).media.item.id.startsWith("a"))
}
}