diff options
Diffstat (limited to 'packages/meshbay-hub/tests')
| -rw-r--r-- | packages/meshbay-hub/tests/test_video_subtitles.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/packages/meshbay-hub/tests/test_video_subtitles.py b/packages/meshbay-hub/tests/test_video_subtitles.py index 9f0c08d..6867076 100644 --- a/packages/meshbay-hub/tests/test_video_subtitles.py +++ b/packages/meshbay-hub/tests/test_video_subtitles.py @@ -110,7 +110,10 @@ def _label_cases(tmp_path, app, cases, locale="en"): ]) script.write_text( f"const getLocale = () => '{locale}';\n" - "const t = (k, p) => `${k}:${p.n}`;\n" + # Not every key is interpolated — the forced/SDH qualifiers take no + # parameters — and a stub that assumes one throws where the real `t` + # returns a string. A fixture narrower than production tests itself. + "const t = (k, p) => (p ? `${k}:${p.n}` : k);\n" + src + "\nconst out = JSON.parse(process.argv[2]).map(subtitleTrackLabel);\n" "console.log(JSON.stringify(out));\n") @@ -150,6 +153,38 @@ def test_the_container_title_tells_a_forced_track_from_a_full_one(tmp_path, app) assert "Forced" in out[0] and "SDH" in out[1] +def test_a_forced_track_is_named_as_one_in_the_reader_s_language(tmp_path, app): + """The entry that was reported as a broken feature. + + A forced track shows signage and foreign dialogue only — on a real film, + 77 seconds of text across 2h32 — so picking it and seeing nothing is its + normal behaviour. It has to be possible to tell it from the full track + beside it, which carries the same language tag, and the disposition says + so where the container's English title tag is often simply absent. + """ + out = _label_cases(tmp_path, app, [ + {"i": 0, "lang": "fre", "forced": True}, + {"i": 1, "lang": "fre"}, + {"i": 2, "lang": "eng", "sdh": True}, + ]) + assert out[0] != out[1], f"a forced track must not read like the full one: {out}" + # The catalogues are stubbed here, so what is asserted is that the label + # goes through `t` at all: the qualifier has to be translated, not the + # English word a muxer typed into the container. + assert out[0] == 'French — video.subtitles_forced', out + assert out[1] == 'French', out + assert out[2] == 'English — video.subtitles_sdh', out + + +def test_the_disposition_wins_over_the_container_title(tmp_path, app): + """A muxer's "Forced" is one spelling of many, and in one language.""" + out = _label_cases(tmp_path, app, [ + {"i": 0, "lang": "fre", "title": "FORCE VF", "forced": True}, + ]) + assert 'FORCE VF' not in out[0], out + assert out[0] == 'French — video.subtitles_forced', out + + def test_an_untagged_track_is_numbered_not_called_unknown(tmp_path, app): """A file with no language tags still needs distinguishable entries.""" out = _label_cases(tmp_path, app, [{"i": 3, "lang": None}, {"i": 4, "lang": "und"}]) |