Spaces:
Sleeping
Sleeping
Download tests/unit/test_runtime_config.py from jrrribeiro/BirdNET-Validator-App: direct link, hf CLI and curl.
- Browser
- Download file 2.19 kB
-
https://huggingface.co/spaces/jrrribeiro/BirdNET-Validator-App/resolve/main/tests/unit/test_runtime_config.py
- Command line
-
hf download hf://spaces/jrrribeiro/BirdNET-Validator-App/tests/unit/test_runtime_config.py
-
curl -L -o test_runtime_config.py https://huggingface.co/spaces/jrrribeiro/BirdNET-Validator-App/resolve/main/tests/unit/test_runtime_config.py
2.19 kB
| from src.config.runtime_config import RuntimeConfig | |
| def test_runtime_config_reads_hf_project_state_writes_flag(monkeypatch) -> None: # noqa: ANN001 | |
| monkeypatch.setenv("BIRDNET_HF_PROJECT_STATE_WRITES_ENABLED", "true") | |
| config = RuntimeConfig.from_env() | |
| assert config.hf_project_state_writes_enabled is True | |
| def test_runtime_config_disables_hf_project_state_writes_by_default(monkeypatch) -> None: # noqa: ANN001 | |
| monkeypatch.delenv("BIRDNET_HF_PROJECT_STATE_WRITES_ENABLED", raising=False) | |
| config = RuntimeConfig.from_env() | |
| assert config.hf_project_state_writes_enabled is False | |
| def test_runtime_config_reads_hf_project_state_repo_list(monkeypatch) -> None: # noqa: ANN001 | |
| monkeypatch.setenv("BIRDNET_HF_PROJECT_STATE_REPOS", "owner/a_state; owner/b_state,\nowner/c_state") | |
| config = RuntimeConfig.from_env() | |
| assert config.hf_project_state_repos == ("owner/a_state", "owner/b_state", "owner/c_state") | |
| def test_runtime_config_reads_bucket_validation_flag(monkeypatch) -> None: # noqa: ANN001 | |
| monkeypatch.setenv("BIRDNET_HF_BUCKET_VALIDATIONS_ENABLED", "true") | |
| config = RuntimeConfig.from_env() | |
| assert config.hf_bucket_validations_enabled is True | |
| def test_runtime_config_reads_hf_admin_storage_mode_flag(monkeypatch) -> None: # noqa: ANN001 | |
| monkeypatch.setenv("BIRDNET_HF_ADMIN_STORAGE_MODE_ENABLED", "true") | |
| config = RuntimeConfig.from_env() | |
| assert config.hf_admin_storage_mode_enabled is True | |
| def test_runtime_config_disables_hf_admin_storage_mode_by_default(monkeypatch) -> None: # noqa: ANN001 | |
| monkeypatch.delenv("BIRDNET_HF_ADMIN_STORAGE_MODE_ENABLED", raising=False) | |
| monkeypatch.delenv("BIRDNET_HF_STORAGE_TOKEN", raising=False) | |
| config = RuntimeConfig.from_env() | |
| assert config.hf_admin_storage_mode_enabled is False | |
| def test_runtime_config_enables_hf_admin_storage_mode_when_dedicated_secret_exists(monkeypatch) -> None: # noqa: ANN001 | |
| monkeypatch.delenv("BIRDNET_HF_ADMIN_STORAGE_MODE_ENABLED", raising=False) | |
| monkeypatch.setenv("BIRDNET_HF_STORAGE_TOKEN", "hf_storage_secret") | |
| config = RuntimeConfig.from_env() | |
| assert config.hf_admin_storage_mode_enabled is True | |