test: 5 final agents — fix 40+ failures, llm_analysis 80%+, git_plugin 90%+, routes 90-98%, services 98-100%, core 90-100%. Coverage: real 87%, target 95%+
This commit is contained in:
@@ -145,6 +145,17 @@ class TestDeleteFile:
|
||||
class TestDownloadFile:
|
||||
"""GET /api/storage/download/{category}/{path}"""
|
||||
|
||||
def test_success(self):
|
||||
client, mock_loader = _make_client()
|
||||
mock_plugin = MagicMock()
|
||||
mock_plugin.get_file_path.return_value = "/tmp/storage/backups/test.txt"
|
||||
mock_loader.get_plugin.return_value = mock_plugin
|
||||
with patch("src.api.routes.storage.FileResponse") as MockFR:
|
||||
MockFR.return_value = {"status": "ok"}
|
||||
resp = client.get(f"{P}/download/backups/test.txt")
|
||||
assert resp.status_code == 200
|
||||
mock_plugin.get_file_path.assert_called_once_with("backups", "test.txt")
|
||||
|
||||
def test_not_found(self):
|
||||
client, mock_loader = _make_client()
|
||||
mock_plugin = MagicMock()
|
||||
@@ -171,6 +182,33 @@ class TestDownloadFile:
|
||||
class TestGetFileByPath:
|
||||
"""GET /api/storage/file"""
|
||||
|
||||
def test_success_relative_path(self):
|
||||
client, mock_loader = _make_client()
|
||||
mock_plugin = MagicMock()
|
||||
mock_plugin.get_storage_root.return_value = Path("/storage/root")
|
||||
mock_plugin.validate_path.return_value = Path("/storage/root/test.txt")
|
||||
mock_loader.get_plugin.return_value = mock_plugin
|
||||
with patch("src.api.routes.storage.FileResponse") as MockFR, \
|
||||
patch("pathlib.Path.exists", return_value=True), \
|
||||
patch("pathlib.Path.is_file", return_value=True):
|
||||
MockFR.return_value = {"status": "ok"}
|
||||
resp = client.get(f"{P}/file?path=test.txt")
|
||||
assert resp.status_code == 200
|
||||
|
||||
def test_success_absolute_path(self):
|
||||
client, mock_loader = _make_client()
|
||||
mock_plugin = MagicMock()
|
||||
mock_plugin.validate_path.return_value = Path("/valid/path/file.txt")
|
||||
mock_loader.get_plugin.return_value = mock_plugin
|
||||
with patch("src.api.routes.storage.FileResponse") as MockFR, \
|
||||
patch("pathlib.Path.exists", return_value=True), \
|
||||
patch("pathlib.Path.is_file", return_value=True), \
|
||||
patch("pathlib.Path.is_absolute", return_value=True):
|
||||
MockFR.return_value = {"status": "ok"}
|
||||
resp = client.get(f"{P}/file?path=/absolute/path/file.txt")
|
||||
assert resp.status_code == 200
|
||||
mock_plugin.validate_path.assert_called_once()
|
||||
|
||||
def test_missing_path(self):
|
||||
client, mock_loader = _make_client()
|
||||
mock_plugin = MagicMock()
|
||||
|
||||
Reference in New Issue
Block a user