File size: 954 Bytes
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
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"


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)