1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-01 19:02:18 +01:00

Allow disabling OTA for web_server while keeping it enabled for captive_portal (#9583)

This commit is contained in:
J. Nick Koston
2025-07-16 17:05:09 -10:00
committed by GitHub
parent 02999195cd
commit b1655b3fd4
5 changed files with 46 additions and 20 deletions

View File

@@ -8,31 +8,31 @@ from esphome.types import ConfigType
def test_web_server_ota_true_fails_validation() -> None:
"""Test that web_server with ota: true fails validation with helpful message."""
from esphome.components.web_server import validate_ota_removed
from esphome.components.web_server import validate_ota
# Config with ota: true should fail
config: ConfigType = {"ota": True}
with pytest.raises(cv.Invalid) as exc_info:
validate_ota_removed(config)
validate_ota(config)
# Check error message contains migration instructions
error_msg = str(exc_info.value)
assert "has been removed from 'web_server'" in error_msg
assert "only accepts 'false' to disable OTA" in error_msg
assert "platform: web_server" in error_msg
assert "ota:" in error_msg
def test_web_server_ota_false_passes_validation() -> None:
"""Test that web_server with ota: false passes validation."""
from esphome.components.web_server import validate_ota_removed
from esphome.components.web_server import validate_ota
# Config with ota: false should pass
config: ConfigType = {"ota": False}
result = validate_ota_removed(config)
result = validate_ota(config)
assert result == config
# Config without ota should also pass
config: ConfigType = {}
result = validate_ota_removed(config)
result = validate_ota(config)
assert result == config