49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
|
|
"""Tests for storage-related API readiness endpoints."""
|
||
|
|
|
||
|
|
from fastapi.testclient import TestClient
|
||
|
|
|
||
|
|
import atocore.config as config
|
||
|
|
from atocore.main import app
|
||
|
|
|
||
|
|
|
||
|
|
def test_sources_endpoint_reports_configured_sources(tmp_data_dir, monkeypatch):
|
||
|
|
vault_dir = tmp_data_dir / "vault-source"
|
||
|
|
drive_dir = tmp_data_dir / "drive-source"
|
||
|
|
vault_dir.mkdir()
|
||
|
|
drive_dir.mkdir()
|
||
|
|
|
||
|
|
monkeypatch.setenv("ATOCORE_VAULT_SOURCE_DIR", str(vault_dir))
|
||
|
|
monkeypatch.setenv("ATOCORE_DRIVE_SOURCE_DIR", str(drive_dir))
|
||
|
|
config.settings = config.Settings()
|
||
|
|
|
||
|
|
client = TestClient(app)
|
||
|
|
response = client.get("/sources")
|
||
|
|
|
||
|
|
assert response.status_code == 200
|
||
|
|
body = response.json()
|
||
|
|
assert body["vault_enabled"] is True
|
||
|
|
assert body["drive_enabled"] is True
|
||
|
|
assert len(body["sources"]) == 2
|
||
|
|
assert all(source["read_only"] for source in body["sources"])
|
||
|
|
|
||
|
|
|
||
|
|
def test_health_endpoint_exposes_machine_paths_and_source_readiness(tmp_data_dir, monkeypatch):
|
||
|
|
vault_dir = tmp_data_dir / "vault-source"
|
||
|
|
drive_dir = tmp_data_dir / "drive-source"
|
||
|
|
vault_dir.mkdir()
|
||
|
|
drive_dir.mkdir()
|
||
|
|
|
||
|
|
monkeypatch.setenv("ATOCORE_VAULT_SOURCE_DIR", str(vault_dir))
|
||
|
|
monkeypatch.setenv("ATOCORE_DRIVE_SOURCE_DIR", str(drive_dir))
|
||
|
|
config.settings = config.Settings()
|
||
|
|
|
||
|
|
client = TestClient(app)
|
||
|
|
response = client.get("/health")
|
||
|
|
|
||
|
|
assert response.status_code == 200
|
||
|
|
body = response.json()
|
||
|
|
assert body["status"] == "ok"
|
||
|
|
assert body["sources_ready"] is True
|
||
|
|
assert "db_path" in body["machine_paths"]
|
||
|
|
assert "run_dir" in body["machine_paths"]
|