0.99.9: the confirmed After Dark, Horror, Evidence, Odyssey and Terra events are appointments; block eligibility worked out once per pool
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.time.DayOfWeek
|
||||
|
||||
/** The confirmed events become appointments (4 November 2026): they start near their hour, with nothing cut and no gaps. */
|
||||
class EventAppointmentsTest {
|
||||
private val zone = java.time.ZoneId.of("Europe/London")
|
||||
private val day = 24 * 60 * 60_000L
|
||||
private val monday = java.time.LocalDate.of(2026, 11, 16).atStartOfDay(zone).toInstant().toEpochMilli()
|
||||
private fun channel(n: Int) = SmartChannels.first { it.number == n }
|
||||
|
||||
@Test fun theFiveChannelsEventsAreAppointments() {
|
||||
val after = channel(AFTER_DARK_NUMBER).dayParts.filter { it.key.startsWith("afterdark.") }
|
||||
assertEquals(listOf(21, 21, 21), after.map { it.fromHour }); assertTrue(after.all { it.onTime })
|
||||
assertTrue(channel(304).dayParts.single { it.key == "horror.slasher" }.let { it.onTime && it.fromHour == 20 })
|
||||
assertTrue(channel(107).dayParts.single { it.days == setOf(DayOfWeek.SUNDAY) }.let { it.onTime && it.fromHour == 20 })
|
||||
assertTrue(channel(202).dayParts.single { it.days.isNotEmpty() }.let { it.onTime && it.fromHour == 14 })
|
||||
assertTrue(channel(201).dayParts.single { it.key == "terra.sunday" }.let { it.onTime && it.fromHour == 20 })
|
||||
}
|
||||
|
||||
@Test fun aFilmEventStartsNearItsHourWithNothingCut() {
|
||||
val films = (1..120).map { PoolSeries("f$it", "Film $it", listOf(PoolEpisode("f$it", "s", EpisodeMark(1, 1), "Film $it", (82L + it * 7 % 45) * 60_000L))) }
|
||||
val parts = listOf(DayPart(21, 1, films.take(20).map { it.title }, days = setOf(DayOfWeek.FRIDAY), onTime = true, key = "test.event"), DayPart(0, 24))
|
||||
val plan = extendFilmSchedule(films, ScheduleCursor(), monday, monday + 21 * day, 7 * day, parts, zone)
|
||||
plan.entries.zipWithNext().forEach { (a, b) -> assertEquals(a.endMs, b.startMs) }
|
||||
val starts = plan.entries.filter { it.presentation == "test.event" && java.time.Instant.ofEpochMilli(it.startMs).atZone(zone).hour >= 21 }.groupBy { java.time.Instant.ofEpochMilli(it.startMs).atZone(zone).toLocalDate() }
|
||||
.map { (date, es) -> (es.minOf { it.startMs } - date.atTime(21, 0).atZone(zone).toInstant().toEpochMilli()) / 60_000 }
|
||||
assertEquals(3, starts.size)
|
||||
assertTrue("late by $starts", starts.all { it in 0..20 })
|
||||
assertTrue(plan.entries.all { it.media.durationMs == films.first { f -> f.id == it.seriesId }.episodes.first().durationMs })
|
||||
}
|
||||
|
||||
@Test fun aWeightedEventStartsNearItsHour() {
|
||||
fun show(t: String, minutes: Int) = PoolSeries(t, t, (1..200).map { PoolEpisode("$t-$it", "s", EpisodeMark(1, it), "E$it", minutes * 60_000L) })
|
||||
val pool = listOf(show("A", 47), show("B", 58), show("C", 89), show("Event", 95))
|
||||
val parts = listOf(DayPart(20, 22, listOf("Event"), days = setOf(DayOfWeek.SUNDAY), onTime = true), DayPart(0, 24, listOf("A", "B", "C")))
|
||||
val plan = extendWeighted(pool, ScheduleCursor(), monday, monday + 21 * day, { TIER_SUPPORTING }, parts, zone, { _, _, _ -> false }, false, { false })
|
||||
plan.entries.zipWithNext().forEach { (a, b) -> assertEquals(a.endMs, b.startMs) }
|
||||
val starts = plan.entries.filter { it.seriesId == "Event" }.groupBy { java.time.Instant.ofEpochMilli(it.startMs).atZone(zone).toLocalDate() }
|
||||
.map { (date, es) -> (es.minOf { it.startMs } - date.atTime(20, 0).atZone(zone).toInstant().toEpochMilli()) / 60_000 }
|
||||
assertEquals(3, starts.size)
|
||||
assertTrue("late by $starts", starts.all { it in 0..20 })
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ class LastDriveInTest {
|
||||
episodes.forEach { e ->
|
||||
val start = local(e.startMs)
|
||||
assertEquals(java.time.DayOfWeek.SATURDAY, start.dayOfWeek)
|
||||
assertTrue("starts in the first slot after 20:00, so around 21:00: $start", start.hour in 20..21)
|
||||
// An appointment at 21:00 since 4 November 2026: the film before it is chosen to finish in time.
|
||||
assertTrue("starts at 21:00 or within its grace: $start", start.hour == 21 && start.minute <= 20)
|
||||
assertEquals("played whole", joeBob.episodes[e.mark.episode - 1].durationMs, e.media.durationMs)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user