Spaces:
Runtime error
Runtime error
File size: 1,471 Bytes
60e41bb 92abc07 60e41bb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 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)
|