Buckets:
AnonymousSpottedToad/human_verified_bucket / codebase /python /Quansight_ragna /tests /deploy /test_config.py
| import os | |
| from pathlib import Path | |
| from urllib.parse import urlsplit | |
| import pytest | |
| from ragna.core import RagnaException | |
| from ragna.deploy import Config | |
| def test_env_var_prefix(mocker, tmp_path): | |
| env_var = tmp_path / "env_var" | |
| mocker.patch.dict(os.environ, values={"RAGNA_LOCAL_ROOT": str(env_var)}) | |
| config = Config() | |
| assert config.local_root == env_var | |
| def test_explicit_gt_env_var(mocker, tmp_path): | |
| explicit = tmp_path / "explicit" | |
| env_var = tmp_path / "env_var" | |
| mocker.patch.dict(os.environ, values={"RAGNA_LOCAL_ROOT": str(env_var)}) | |
| config = Config(local_root=explicit) | |
| assert config.local_root == explicit | |
| def test_env_var_gt_config_file(mocker, tmp_path): | |
| config_file = tmp_path / "config_file" | |
| config = Config(local_root=config_file) | |
| assert config.local_root == config_file | |
| config_path = tmp_path / "ragna.toml" | |
| config.to_file(config_path) | |
| env_var = tmp_path / "env_var" | |
| mocker.patch.dict(os.environ, values={"RAGNA_LOCAL_ROOT": str(env_var)}) | |
| config = Config.from_file(config_path) | |
| assert config.local_root == env_var | |
| def test_api_database_url_default_path(tmp_path): | |
| config = Config(local_root=tmp_path) | |
| assert Path(urlsplit(config.database_url).path[1:]).parent == tmp_path | |
| def test_origins_default(): | |
| hostname, port = "0.0.0.0", "80" | |
| config = Config(hostname=hostname, port=port) | |
| assert config.origins == [f"http://{hostname}:{port}"] | |
| def test_from_file_path_not_exists(tmp_path): | |
| with pytest.raises(RagnaException, match="does not exist"): | |
| Config.from_file(tmp_path / "ragna.toml") | |
| def test_from_file_path_exists(tmp_path): | |
| config_path = tmp_path / "ragna.toml" | |
| open(config_path, "w").close() | |
| with pytest.raises(RagnaException, match="already exists"): | |
| Config().to_file(config_path) | |
| def test_from_file_path_exists_force(tmp_path): | |
| config_path = tmp_path / "ragna.toml" | |
| open(config_path, "w").close() | |
| config = Config(local_root=tmp_path) | |
| config.to_file(config_path, force=True) | |
| assert Config.from_file(config_path).local_root == tmp_path | |
Xet Storage Details
- Size:
- 2.13 kB
- Xet hash:
- dd10aa67218aa34b2e975945a01c81de9e28951eba3e742afde5609362ba89e1
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.