forked from kenzuya/unshackle
refactor(temp): read the free space where the failed step deletes its temp files
This commit is contained in:
@@ -21,7 +21,7 @@ import unshackle.commands.dl as dl_module
|
||||
from tests.admission import refusal
|
||||
from tests.remote.sessions import launch_session
|
||||
from tests.remote.unit.test_remote_service_helpers import _sent_create_data
|
||||
from unshackle.core import mux_step
|
||||
from unshackle.core import mux_step, temp
|
||||
from unshackle.core.api import download_manager, handlers, key_policy
|
||||
from unshackle.core.config import config
|
||||
from unshackle.core.mux_step import hybrid_plan, hybrid_source_tracks, hybrid_step_error, missing_hybrid_error
|
||||
@@ -705,10 +705,38 @@ def test_a_hybrid_failure_is_reported_so_the_title_goes_on(monkeypatch: pytest.M
|
||||
raise error
|
||||
|
||||
monkeypatch.setattr(mux_step, "Hybrid", failed_hybrid)
|
||||
monkeypatch.setattr(temp, "LOW_FREE_SPACE", 0)
|
||||
|
||||
assert hybrid_step_error([], "TEST", "HDR10-DV-2160p.hevc") == str(error)
|
||||
|
||||
|
||||
def test_a_hybrid_that_fills_the_temp_volume_names_the_free_space_before_its_files_go(
|
||||
quiet: None, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||
) -> None:
|
||||
base = tmp_path / "base.mkv"
|
||||
base.write_bytes(b"")
|
||||
stream = tmp_path / "HDR10.hevc"
|
||||
present: list[bool] = []
|
||||
|
||||
def full(self: Hybrid) -> None:
|
||||
stream.write_bytes(b"hevc")
|
||||
raise OSError(28, "No space left on device")
|
||||
|
||||
def usage(path: Any) -> Any:
|
||||
present.append(stream.exists())
|
||||
return SimpleNamespace(free=38_000_000)
|
||||
|
||||
stub_hybrid_steps(monkeypatch, "measure_dv", "level_6")
|
||||
monkeypatch.setattr(Hybrid, "injecting", full)
|
||||
monkeypatch.setattr(temp.shutil, "disk_usage", usage)
|
||||
video = SimpleNamespace(id="b", path=base, width=None, height=2160, range=Video.Range.HDR10)
|
||||
|
||||
error = hybrid_step_error([video], "TEST", "HDR10-DV-2160p.hevc") # type: ignore[list-item]
|
||||
|
||||
assert error == f"[Errno 28] No space left on device, 38.0 MB free on {tmp_path}"
|
||||
assert present == [True] and not stream.exists()
|
||||
|
||||
|
||||
def test_a_working_hybrid_reports_no_error_and_an_exit_passes_through(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
seen: dict[str, Any] = {}
|
||||
monkeypatch.setattr(mux_step, "Hybrid", lambda tracks, source, output_name: seen.update(name=output_name))
|
||||
|
||||
Reference in New Issue
Block a user