feat: storage management — disk usage, cleanup API, scheduled cleanup task

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-03 22:32:36 +05:00
parent b1eafa4e0b
commit 397b999558
4 changed files with 117 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
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