aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_audio_transcode.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/tests/test_audio_transcode.py')
-rw-r--r--packages/meshbay-node/tests/test_audio_transcode.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/packages/meshbay-node/tests/test_audio_transcode.py b/packages/meshbay-node/tests/test_audio_transcode.py
index c2f7f64..a6557f0 100644
--- a/packages/meshbay-node/tests/test_audio_transcode.py
+++ b/packages/meshbay-node/tests/test_audio_transcode.py
@@ -1,6 +1,6 @@
"""
Tests for the Music app's one exception to "no node-side transcode pool"
-(docs/musicbay.md §2.2): WMA and Musepack tag/cover fine (enrich_audio.py)
+(docs/MESHBAY_DESIGN.md §9.8): WMA and Musepack tag/cover fine (enrich_audio.py)
but decode in no mainstream browser's <audio> element at all, so
`_do_audio_transcode_request` converts to AAC/M4A on request and caches the
result — served back through the ordinary file_req/chunk path, generalized
@@ -191,3 +191,39 @@ async def test_multi_chunk_cached_blob_reassembles_correctly(tmp_path, media_cac
assert len(chunk_msgs) == total_chunks
reassembled = _reassemble_file_chunks(session.sent, gek, blob_hash)
assert reassembled == blob
+
+
+async def test_only_the_two_formats_that_need_it_are_transcoded(tmp_path, media_cache):
+ """
+ The gate that was written down and never applied.
+
+ `BROWSER_INCOMPATIBLE_AUDIO_EXTS` was read by nobody: the player asked only
+ for `.wma` and `.mpc`, and the node converted whatever file id it was given.
+ A member's own message is not the player, and this conversion is whole-file
+ while holding a transcode slot shared with video streaming — so one message
+ naming a two-hour film spends minutes of the operator's CPU and a slot every
+ other viewer is queued behind. The size cap catches the result; only this
+ catches the work.
+ """
+ clip = tmp_path / "feature.mkv"
+ clip.write_bytes(b"not really a film, and never opened")
+ session, file_id = _session(tmp_path, clip, generate_gek(), media_cache)
+
+ await session._do_audio_transcode_request({"file_id": file_id})
+
+ (msg,) = session.sent
+ assert msg["type"] == "error"
+ assert msg["code"] == "transcode_not_applicable"
+
+
+@pytest.mark.skipif(not _HAVE_FFMPEG, reason="ffmpeg/ffprobe not installed")
+async def test_the_two_formats_that_do_need_it_still_pass(tmp_path, media_cache):
+ """The gate must admit what it exists for; a refusal of everything is not a gate."""
+ clip = tmp_path / "clip.wma"
+ _make_wma_clip(clip)
+ session, file_id = _session(tmp_path, clip, generate_gek(), media_cache)
+
+ await session._do_audio_transcode_request({"file_id": file_id})
+
+ assert [m for m in session.sent if m.get("type") == MNP.AUDIO_TRANSCODE_RESP], (
+ f"a WMA file was refused: {session.sent}")