Release v1.0.11: shared runtime diagnostics and media_assets probe helpers
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 23s
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 23s
This commit is contained in:
@@ -15,7 +15,7 @@ from jiangchang_skill_core import media_assets as ma
|
||||
|
||||
def _make_complete_assets(root: Path, *, with_ffmpeg: bool = True, with_ffprobe: bool = True) -> None:
|
||||
(root / "music" / "calm").mkdir(parents=True)
|
||||
(root / "music" / "calm" / "track.mp3").write_bytes(b"x" * 256)
|
||||
(root / "music" / "calm" / "track.mp3").write_bytes(b"x" * 1024)
|
||||
(root / "fonts").mkdir(parents=True)
|
||||
(root / "watermark").mkdir(parents=True)
|
||||
bin_key = ma._platform_bin_key()
|
||||
@@ -63,7 +63,7 @@ def _build_archive_zip(dest: Path, inner_name: str) -> None:
|
||||
with zipfile.ZipFile(dest, "w") as zf:
|
||||
zf.writestr(f"{inner_name}/README.md", "# media-assets\n")
|
||||
zf.writestr(f"{inner_name}/manifest.json", json.dumps(manifest, ensure_ascii=False))
|
||||
zf.writestr(f"{inner_name}/music/calm/track.mp3", b"x" * 256)
|
||||
zf.writestr(f"{inner_name}/music/calm/track.mp3", b"x" * 1024)
|
||||
zf.writestr(f"{inner_name}/fonts/.keep", "")
|
||||
zf.writestr(f"{inner_name}/watermark/.keep", "")
|
||||
|
||||
@@ -168,9 +168,9 @@ def test_pick_background_music_stable_first(tmp_path: Path, monkeypatch: pytest.
|
||||
root = tmp_path / "data" / "shared" / "media-assets"
|
||||
_make_complete_assets(root)
|
||||
music = root / "music"
|
||||
(music / "b-upbeat.mp3").write_bytes(b"x" * 256)
|
||||
(music / "calm" / "a-calm.mp3").write_bytes(b"x" * 256)
|
||||
(music / "z-last.wav").write_bytes(b"x" * 256)
|
||||
(music / "b-upbeat.mp3").write_bytes(b"x" * 1024)
|
||||
(music / "calm" / "a-calm.mp3").write_bytes(b"x" * 1024)
|
||||
(music / "z-last.wav").write_bytes(b"x" * 1024)
|
||||
|
||||
monkeypatch.setattr(
|
||||
ma,
|
||||
@@ -297,7 +297,7 @@ def test_pick_background_music_skips_lfs_pointer(tmp_path: Path, monkeypatch: py
|
||||
_make_complete_assets(root, with_ffmpeg=True, with_ffprobe=True)
|
||||
music = root / "music"
|
||||
(music / "calm" / "track.mp3").unlink()
|
||||
(music / "real.mp3").write_bytes(b"x" * 256)
|
||||
(music / "real.mp3").write_bytes(b"x" * 1024)
|
||||
lfs = music / "lfs-only.mp3"
|
||||
lfs.write_text("version https://git-lfs.github.com/spec/v1\noid sha256:abc\nsize 123\n")
|
||||
|
||||
@@ -390,7 +390,7 @@ def test_video_finalize_without_music_fallback(tmp_path: Path, monkeypatch: pyte
|
||||
def test_manifest_ffmpeg_download(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
root = tmp_path / "data" / "shared" / "media-assets"
|
||||
(root / "music" / "calm").mkdir(parents=True)
|
||||
(root / "music" / "calm" / "track.mp3").write_bytes(b"x" * 256)
|
||||
(root / "music" / "calm" / "track.mp3").write_bytes(b"x" * 1024)
|
||||
(root / "fonts").mkdir(parents=True)
|
||||
(root / "watermark").mkdir(parents=True)
|
||||
(root / "manifest.json").write_text(
|
||||
@@ -406,3 +406,32 @@ def test_manifest_ffmpeg_download(tmp_path: Path, monkeypatch: pytest.MonkeyPatc
|
||||
assert status.ready is True
|
||||
assert status.ffmpeg_path is not None
|
||||
assert status.ffprobe_path is not None
|
||||
|
||||
|
||||
def test_is_usable_audio_file_rejects_small_and_lfs(tmp_path: Path) -> None:
|
||||
small = tmp_path / "small.mp3"
|
||||
small.write_bytes(b"x" * 512)
|
||||
assert ma.is_usable_audio_file(small) is False
|
||||
|
||||
ok = tmp_path / "ok.mp3"
|
||||
ok.write_bytes(b"x" * 1024)
|
||||
assert ma.is_usable_audio_file(ok) is True
|
||||
|
||||
lfs = tmp_path / "lfs.mp3"
|
||||
lfs.write_text("version https://git-lfs.github.com/spec/v1\noid sha256:abc\nsize 123\n")
|
||||
assert ma.is_usable_audio_file(lfs) is False
|
||||
assert ma.is_git_lfs_pointer(lfs) is True
|
||||
|
||||
|
||||
def test_probe_background_music_structure(tmp_path: Path) -> None:
|
||||
root = tmp_path / "media-assets"
|
||||
music = root / "music" / "calm"
|
||||
music.mkdir(parents=True)
|
||||
(music / "track.mp3").write_bytes(b"x" * 1024)
|
||||
|
||||
probe = ma.probe_background_music(root)
|
||||
assert probe["music_root"] == str(root / "music")
|
||||
assert probe["mp3_count"] == 1
|
||||
assert probe["usable_count"] == 1
|
||||
assert probe["issue"] is None
|
||||
assert probe["sample_path"] == str(music / "track.mp3")
|
||||
|
||||
Reference in New Issue
Block a user