waterleaf / tests /test_runtime.py
hkaraoguz's picture
Fix SQLite disk I/O on bucket mount
92abc07 verified
Raw
History Blame
1.47 kB
from waterleaf.runtime import build_application
from waterleaf.services.demo import DemoTaxonomy
from waterleaf.settings import Settings
def test_settings_derive_public_url_from_space_host(monkeypatch, tmp_path):
monkeypatch.setenv("SPACE_HOST", "hkaraoguz-waterleaf.hf.space")
monkeypatch.setenv("WATERLEAF_DATA_DIR", str(tmp_path))
settings = Settings.from_env()
assert settings.public_base_url == "https://hkaraoguz-waterleaf.hf.space"
assert settings.database_path == tmp_path / "waterleaf.sqlite3"
assert settings.database_snapshot_path is None
def test_settings_can_keep_sqlite_database_off_data_mount(monkeypatch, tmp_path):
data_dir = tmp_path / "data"
database_dir = tmp_path / "db"
monkeypatch.setenv("WATERLEAF_DATA_DIR", str(data_dir))
monkeypatch.setenv("WATERLEAF_DATABASE_DIR", str(database_dir))
settings = Settings.from_env()
assert settings.database_path == database_dir / "waterleaf.sqlite3"
assert settings.database_snapshot_path == data_dir / "waterleaf.sqlite3"
def test_runtime_uses_demo_identification_without_modal_endpoint(tmp_path):
settings = Settings(
data_directory=tmp_path,
public_base_url="http://localhost:7860",
modal_endpoint=None,
modal_key=None,
modal_secret=None,
)
application = build_application(settings)
assert application.identification is not None
assert isinstance(application.taxonomy, DemoTaxonomy)