397b999558
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
667 B
Python
27 lines
667 B
Python
import os
|
|
import pytest
|
|
from unittest.mock import patch
|
|
|
|
from app.services.storage import get_disk_usage, _dir_size
|
|
|
|
|
|
def test_dir_size_empty(tmp_path):
|
|
assert _dir_size(str(tmp_path)) == 0
|
|
|
|
|
|
def test_dir_size_with_files(tmp_path):
|
|
f = tmp_path / "test.bin"
|
|
f.write_bytes(b"\x00" * 1024)
|
|
assert _dir_size(str(tmp_path)) == 1024
|
|
|
|
|
|
def test_dir_size_nonexistent():
|
|
assert _dir_size("/nonexistent/path/12345") == 0
|
|
|
|
|
|
def test_get_disk_usage():
|
|
with patch("app.services.storage._dir_size", return_value=1024 * 1024 * 512):
|
|
result = get_disk_usage()
|
|
assert result["total_bytes"] == 1024 * 1024 * 512 * 2
|
|
assert "total_gb" in result
|