36 lines
962 B
Python
36 lines
962 B
Python
from netatmo_service.config import load_config
|
|||
|
|
|
||
|
|
|
||
|
|
def test_yaml_config_is_loaded_and_relative_paths_are_resolved(tmp_path):
|
||
|
|
config_file = tmp_path / "config.yaml"
|
||
|
|
config_file.write_text(
|
||
|
|
"""
|
||
|
|
server:
|
||
|
|
host: 127.0.0.1
|
||
|
|
port: 12345
|
||
|
|
url_prefix: weather/
|
||
|
|
storage:
|
||
|
|
rrd_folder: data
|
||
|
|
logging:
|
||
|
|
file: logs/service.log
|
||
|
|
collector:
|
||
|
|
enabled: false
|
||
|
|
netatmo:
|
||
|
|
client_id: test-client
|
||
|
|
client_secret: test-secret
|
||
|
|
token_file: secrets/tokens.json
|
||
|
|
modules:
|
||
|
|
study: Office
|
||
|
|
""",
|
||
|
|
encoding="utf-8",
|
||
|
|
)
|
||
|
|
config = load_config(config_file)
|
||
|
|
assert config["HOST"] == "127.0.0.1"
|
||
|
|
assert config["PORT"] == 12345
|
||
|
|
assert config["URL_PREFIX"] == "/weather"
|
||
|
|
assert config["RRD_FOLDER"] == tmp_path / "data"
|
||
|
|
assert config["LOG_FILE"] == tmp_path / "logs/service.log"
|
||
|
|
assert config["NETATMO_TOKEN_FILE"] == tmp_path / "secrets/tokens.json"
|
||
|
|
assert config["START_COLLECTOR"] is False
|
||
|
|
assert config["MODULE_STUDY"] == "Office"
|