File size: 1,844 Bytes
b0821c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a095fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Proves the toolchain works before any real code exists."""

import subprocess
import sys
from pathlib import Path


def test_python_version_matches_space_runtime():
    assert sys.version_info[:2] == (3, 12), (
        "ZeroGPU provides only Python 3.10.13 and 3.12.12; this project pins 3.12.12"
    )


def test_package_importable():
    import japanese_avatar

    assert japanese_avatar.__version__


def test_ruff_and_pytest_configured():
    import tomllib

    cfg = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))
    assert cfg["tool"]["ruff"]["target-version"] == "py312"
    assert "pytest" in cfg["tool"]


def test_lfs_armed_before_any_binary_lands():
    """Plans 01-01 and 01-04 commit tens of megabytes. A non-LFS push of that size is rejected."""
    for path in ("avatar/assets/tutor.vrm", "voicevox/model/zundamon.vvm", "tests/fixtures/x.wav"):
        out = subprocess.run(
            ["git", "check-attr", "filter", "--", path], capture_output=True, text=True, check=True
        ).stdout
        assert "filter: lfs" in out, f"{path} is not LFS-tracked; see .gitattributes"


def test_non_speech_fixtures_exist_and_are_30s(silence_wav, cafe_noise_wav):
    from tests.conftest import wav_duration_seconds

    for p in (silence_wav, cafe_noise_wav):
        assert p.exists(), p
        assert abs(wav_duration_seconds(p) - 30.0) < 0.01


def test_cafe_noise_is_loud_enough_to_defeat_an_rms_only_gate(cafe_noise_wav):
    """If this fixture were quiet, plan 01-07's noise-rejection test would pass trivially."""
    import wave

    import numpy as np

    with wave.open(str(cafe_noise_wav), "rb") as w:
        pcm = np.frombuffer(w.readframes(w.getnframes()), dtype="<i2").astype(np.float64) / 32768.0
    assert float(np.sqrt(np.mean(pcm**2))) > 0.02, "noise fixture too quiet to be a real test"