Handle empty recording days and stale playback queries

This commit is contained in:
Codex
2026-10-03 17:15:09 +08:00
parent 969dcabe99
commit d21170b41d
4 changed files with 30 additions and 8 deletions
+13
View File
@@ -1,6 +1,7 @@
"""Isolated regression tests: python -m unittest -v test_app."""
import hashlib
import http.client
import io
import json
import os
import tempfile
@@ -128,6 +129,18 @@ class WebTests(unittest.TestCase):
self.assertIn('h264_vaapi', command)
self.assertIn('pipe:1', command)
def test_empty_recording_day_is_not_service_failure(self):
error = app.urllib.error.HTTPError('http://localhost/list', 404, 'Not Found', {},
io.BytesIO(b'{"error":"no recording segments found"}'))
with patch('app.urllib.request.urlopen', side_effect=error):
self.assertEqual(app.media_json('/list?path=example', playback=True), [])
def test_real_media_service_error_is_preserved(self):
error = app.urllib.error.HTTPError('http://localhost/list', 500, 'Error', {}, io.BytesIO(b'{}'))
with patch('app.urllib.request.urlopen', side_effect=error):
with self.assertRaises(app.Problem):
app.media_json('/list?path=example', playback=True)
if __name__ == '__main__':
unittest.main()