Follow a series, from the phone: reminders whenever any channel plans one of its episodes in the next day

The phone's programme sheet offers Follow this series for an episode (never a
film). The TV checks every ten minutes, and straight after a follow, adding a
reminder per planned episode as if set in the guide. Per profile; the planner
is never asked for more of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 19:44:48 +00:00
co-authored by Claude Opus 5.5
parent 103a8a9961
commit eb45d5ca45
6 changed files with 118 additions and 4 deletions
@@ -0,0 +1,34 @@
package tv.orbit.classic
import org.junit.Assert.*
import org.junit.Test
/** Follow a series (9 November 2026): reminders for followed series' planned episodes in the next day. */
class FollowSeriesTest {
private val minute = 60_000L
private val now = 1_794_300_000_000L
private fun media(id: String) = ScheduledMedia(SampleItem("Show / S1 E$id / Pilot", "Episode", 30, "", "ep$id", 30 * minute), "src$id", 30 * minute)
private fun channel(number: Int, vararg entries: Pair<String, Long>): ScheduledChannel {
val list = entries.mapIndexed { i, (series, start) -> ScheduleEntry(series, EpisodeMark(1, i + 1), media("$number$i"), start) }
return ScheduledChannel(SampleChannel(listOf(media("${number}x"), media("${number}y")), "Test", number), ChannelPlan(list, ScheduleCursor()))
}
@Test fun remindsForFollowedEpisodesInTheNextDay() {
val c1 = channel(304, "showA" to now + 60 * minute, "showB" to now + 90 * minute, "showA" to now + 26 * 60 * minute)
val c2 = channel(305, "showA" to now + 5 * 60 * minute)
val got = followedReminders(mapOf("showA" to "Show A"), listOf(c1, c2), emptyList(), now)
assertEquals(listOf(304 to now + 60 * minute, 305 to now + 5 * 60 * minute), got.map { it.channel to it.startMs })
}
@Test fun neverTwiceAndNeverPast() {
val c = channel(304, "showA" to now - 10 * minute, "showA" to now + 60 * minute)
val existing = listOf(ProgrammeReminder(304, now + 60 * minute, "Show"))
assertTrue(followedReminders(mapOf("showA" to "Show A"), listOf(c), existing, now).isEmpty())
assertTrue(followedReminders(emptyMap(), listOf(c), emptyList(), now).isEmpty())
}
@Test fun seriesNameFromTheGuideTitle() {
assertEquals("Gavin & Stacey", FollowSeries.seriesName("Gavin & Stacey / S2 E7 / The Baby"))
assertEquals("Train to Busan", FollowSeries.seriesName("Train to Busan"))
}
}