Add library health check, channel logos and remote controls (0.22.0)
A read-only check of duplicates, decades, genres and filter speed, with no database change. Gives 101, 102 and 103 their logos and an on-screen mark, and makes up, down and left change channel while watching. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class CatalogueStatsTest {
|
||||
private fun health(vararg rows: Array<Any?>): CatalogueHealth {
|
||||
val tally = CatalogueTally()
|
||||
rows.forEach { tally.add(it[0] as String, it[1] as String, it[2] as Int?, it[3] as String, it[4] as String, it[5] as String) }
|
||||
return tally.result(0, emptyList(), 0)
|
||||
}
|
||||
private fun film(title: String, year: Int?, ids: String = "{}", genres: String = "", tags: String = "") = arrayOf<Any?>("Movie", title, year, genres, tags, ids)
|
||||
|
||||
@Test fun copiesWithTheSameExternalIdCountAsOneTitle() {
|
||||
val h = health(film("Alien", 1979, """{"Imdb":"tt0078748"}"""), film("Alien Remux", 1979, """{"Imdb":"TT0078748","Tmdb":"348"}"""), film("Aliens", 1986, """{"Imdb":"tt0090605"}"""))
|
||||
assertEquals(3L, h.titles); assertEquals(2L, h.distinctById); assertEquals(1L, h.repeatedById); assertEquals(0L, h.withoutId)
|
||||
}
|
||||
@Test fun titlesAndYearsKeepRemakesApartAndIgnoreSpelling() {
|
||||
assertEquals(catalogueTitleKey("Movie", "The Thing", 1982), catalogueTitleKey("Movie", "thing:", 1982))
|
||||
assertNotEquals(catalogueTitleKey("Movie", "The Thing", 1982), catalogueTitleKey("Movie", "The Thing", 2011))
|
||||
assertNotEquals(catalogueTitleKey("Movie", "Fargo", 1996), catalogueTitleKey("Series", "Fargo", 1996))
|
||||
assertNotEquals(catalogueTitleKey("Movie", "Fargo", null), catalogueTitleKey("Movie", "Fargo", 1996))
|
||||
}
|
||||
@Test fun missingOrBrokenIdsAreCountedNotMerged() {
|
||||
val h = health(film("One", 2000), film("Two", 2000, "not json"), film("Three", 2000, """{"Other":"1"}"""))
|
||||
assertEquals(3L, h.withoutId); assertEquals(3L, h.distinctById); assertEquals(0L, h.repeatedById)
|
||||
assertNull(catalogueIdKey("Movie", "not json"))
|
||||
}
|
||||
@Test fun aFilmAndASeriesCanShareANumber() {
|
||||
assertNotEquals(catalogueIdKey("Movie", """{"Tmdb":"5"}"""), catalogueIdKey("Series", """{"Tmdb":"5"}"""))
|
||||
}
|
||||
@Test fun countsDecadesGenresAndTagsAndSortsThem() {
|
||||
val h = health(film("A", 1985, genres = "Horror|Comedy", tags = "Slasher"), film("B", 1989, genres = "Horror", tags = "slasher|Cult"), film("C", 1991), film("D", null))
|
||||
assertEquals(listOf("1980s" to 2L, "1990s" to 1L), h.decades)
|
||||
assertEquals("Horror" to 2L, h.genres.first()); assertEquals("slasher" to 2L, h.tags.first())
|
||||
}
|
||||
@Test fun upAndDownWrapRoundAndAnUnknownChannelStaysPut() {
|
||||
val lineup = listOf(101, 102, 103)
|
||||
assertEquals(102, channelAfter(lineup, 101, 1)); assertEquals(101, channelAfter(lineup, 103, 1)); assertEquals(103, channelAfter(lineup, 101, -1))
|
||||
assertEquals(999, channelAfter(lineup, 999, 1)); assertEquals(101, channelAfter(listOf(101), 101, 1))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user