0.108.4: Stage D evidence reader (read only, resumable), built on 0.108.3, not installed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
Claude
co-authored by
Claude Opus 5.5
parent
a57d0dfbe1
commit
00153e25bd
@@ -0,0 +1,38 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
/** Stage D's evidence: only what the provider gave, missing kept as missing, and a read that can carry on where it stopped. */
|
||||
class EvidenceReaderTest {
|
||||
private fun row() = JSONObject().put("Id", "8070341").put("Type", "Series").put("Name", "Blue Planet III").put("ProductionYear", 2026)
|
||||
.put("Overview", "The oceans, from the deep sea to the coral reefs.").put("Tags", JSONArray(listOf("ocean", "nature")))
|
||||
.put("Genres", JSONArray(listOf("Documentary"))).put("Studios", JSONArray().put(JSONObject().put("Name", "BBC Studios")))
|
||||
.put("People", JSONArray().put(JSONObject().put("Name", "David Attenborough").put("Type", "GuestStar")).put(JSONObject().put("Name", "A Producer").put("Type", "Producer")))
|
||||
.put("ProviderIds", JSONObject().put("Tmdb", "1"))
|
||||
|
||||
@Test fun keepsWhatTheProviderGave() {
|
||||
val line = evidenceLine(row())!!
|
||||
assertEquals("Blue Planet III", line.getString("name"))
|
||||
assertEquals("ocean", line.getJSONArray("tags").getString(0))
|
||||
assertEquals("David Attenborough", line.getJSONArray("leads").getString(0))
|
||||
assertEquals(0, line.getJSONArray("directors").length())
|
||||
assertEquals("BBC Studios", line.getJSONArray("studios").getString(0))
|
||||
}
|
||||
|
||||
@Test fun missingIsMissingNotNegative() {
|
||||
val bare = evidenceLine(JSONObject().put("Id", "123").put("Type", "Movie").put("Name", "Something"))!!
|
||||
for (key in listOf("overview", "tags", "genres", "leads", "directors", "rating", "year")) assertTrue(key, bare.isNull(key))
|
||||
assertNull(evidenceLine(JSONObject().put("Id", "../bad")))
|
||||
}
|
||||
|
||||
@Test fun aReadCarriesOnWhereItStopped() {
|
||||
val file = File.createTempFile("evidence", ".jsonl").apply { deleteOnExit() }
|
||||
file.writeText(evidenceLine(row()).toString() + "\n")
|
||||
assertEquals(listOf("2", "3"), evidenceMissing(file, listOf("8070341", "2", "3", "2")))
|
||||
assertEquals(listOf("1"), evidenceMissing(File(file.parent, "none-${System.nanoTime()}.jsonl"), listOf("1")))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user