Initial video AI analysis project
This commit is contained in:
30
tests/test_manifest.py
Normal file
30
tests/test_manifest.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from video_ai_analysis_poc.manifest import read_jsonl, write_manifest
|
||||
|
||||
|
||||
class ManifestTests(unittest.TestCase):
|
||||
def test_write_manifest_writes_status_retry_and_error_fields(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "video_manifest.jsonl"
|
||||
records = [
|
||||
{"path": "/tmp/a.mp4", "status": "probed"},
|
||||
{"path": "/tmp/b.mp4", "status": "probe_failed", "last_error": "bad data"},
|
||||
]
|
||||
|
||||
write_manifest(path, records)
|
||||
|
||||
lines = path.read_text(encoding="utf-8").splitlines()
|
||||
decoded = [json.loads(line) for line in lines]
|
||||
self.assertEqual(decoded[0]["retry_count"], 0)
|
||||
self.assertIsNone(decoded[0]["last_error"])
|
||||
self.assertEqual(decoded[1]["status"], "probe_failed")
|
||||
self.assertEqual(decoded[1]["last_error"], "bad data")
|
||||
self.assertEqual(read_jsonl(path), decoded)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user