mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-22 08:48:38 +00:00
OpenHousing logs a job but silently drops the appointment when no bookable resource is sent, so the survey date never lands. log_job already sends the configured default_resource; amend_job omitted the parameter unless the request carried an explicit surveyor. Default amend's resource to the configured surveyor too, and fail loudly at config load on a blank ABRI_RELAY_DEFAULT_RESOURCE so the misconfiguration can't ship an empty resource again. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import pytest
|
|
|
|
from infrastructure.abri.config import AbriConfig
|
|
|
|
|
|
def test_config_hydrates_relay_credentials_and_defaults_from_environment() -> None:
|
|
# Arrange
|
|
env = {
|
|
"ABRI_RELAY_URL": "https://relay.example.test/api/DomnaRelay?code=key",
|
|
"ABRI_RELAY_USERNAME": "DomnaWeb",
|
|
"ABRI_RELAY_PASSWORD": "secret",
|
|
"ABRI_RELAY_DEFAULT_RESOURCE": "CBRYAN",
|
|
}
|
|
|
|
# Act
|
|
config = AbriConfig.from_env(env)
|
|
|
|
# Assert
|
|
assert config == AbriConfig(
|
|
endpoint_url="https://relay.example.test/api/DomnaRelay?code=key",
|
|
username="DomnaWeb",
|
|
password="secret",
|
|
default_resource="CBRYAN",
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize("blank", ["", " "])
|
|
def test_config_rejects_a_blank_default_resource(blank: str) -> None:
|
|
# A blank resource does not error at the relay: OpenHousing logs the job
|
|
# but silently drops the appointment. Fail loudly at config load instead.
|
|
env = {
|
|
"ABRI_RELAY_URL": "https://relay.example.test/api/DomnaRelay?code=key",
|
|
"ABRI_RELAY_USERNAME": "DomnaWeb",
|
|
"ABRI_RELAY_PASSWORD": "secret",
|
|
"ABRI_RELAY_DEFAULT_RESOURCE": blank,
|
|
}
|
|
|
|
with pytest.raises(ValueError, match="ABRI_RELAY_DEFAULT_RESOURCE"):
|
|
AbriConfig.from_env(env)
|