"""Тесты CLI-монитора прогресса.""" from __future__ import annotations from src.cli.progress import Snapshot, format_duration, human_int, render_bar def test_render_bar_empty(): assert render_bar(0) == "░" * 30 def test_render_bar_full(): assert render_bar(1) == "█" * 30 def test_render_bar_half(): bar = render_bar(0.5, width=10) assert bar == "█" * 5 + "░" * 5 def test_render_bar_clamps_fraction(): assert render_bar(-1, width=4) == "░░░░" assert render_bar(2, width=4) == "████" def test_format_duration(): assert format_duration(None) == "—" assert format_duration(42) == "42s" assert format_duration(24 * 60) == "24m" assert format_duration(3600 + 5 * 60) == "1h 05m" def test_human_int(): assert human_int(1234567) == "1 234 567" def test_progress_line_contains_key_numbers(): from src.cli.progress import _format_line snapshot = Snapshot( key="input/data.csv", rows=50_000, points=49_000, total_rows=100_000, rate=100.0, ) line = _format_line(snapshot) assert "50.0%" in line assert "50 000" in line assert "100 000" in line assert "49 000" in line assert "ETA" in line