mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 08:15:49 +00:00
Merge branch 'ble_client_automation_no_heap' into integration
This commit is contained in:
47
tests/components/hlk_fm22x/test.esp32-idf.yaml
Normal file
47
tests/components/hlk_fm22x/test.esp32-idf.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
esphome:
|
||||
on_boot:
|
||||
then:
|
||||
- hlk_fm22x.enroll:
|
||||
name: "Test"
|
||||
direction: 1
|
||||
- hlk_fm22x.delete_all:
|
||||
|
||||
uart:
|
||||
- id: uart_hlk_fm22x
|
||||
tx_pin: 17
|
||||
rx_pin: 16
|
||||
baud_rate: 115200
|
||||
|
||||
hlk_fm22x:
|
||||
on_face_scan_matched:
|
||||
- logger.log: test_hlk_22x_face_scan_matched
|
||||
on_face_scan_unmatched:
|
||||
- logger.log: test_hlk_22x_face_scan_unmatched
|
||||
on_face_scan_invalid:
|
||||
- logger.log: test_hlk_22x_face_scan_invalid
|
||||
on_face_info:
|
||||
- logger.log: test_hlk_22x_face_info
|
||||
on_enrollment_done:
|
||||
- logger.log: test_hlk_22x_enrollment_done
|
||||
on_enrollment_failed:
|
||||
- logger.log: test_hlk_22x_enrollment_failed
|
||||
|
||||
sensor:
|
||||
- platform: hlk_fm22x
|
||||
face_count:
|
||||
name: "Face Count"
|
||||
last_face_id:
|
||||
name: "Last Face ID"
|
||||
status:
|
||||
name: "Face Status"
|
||||
|
||||
binary_sensor:
|
||||
- platform: hlk_fm22x
|
||||
name: "Face Enrolling"
|
||||
|
||||
text_sensor:
|
||||
- platform: hlk_fm22x
|
||||
version:
|
||||
name: "HLK Version"
|
||||
last_face_name:
|
||||
name: "Last Face Name"
|
||||
47
tests/components/hlk_fm22x/test.esp8266-ard.yaml
Normal file
47
tests/components/hlk_fm22x/test.esp8266-ard.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
esphome:
|
||||
on_boot:
|
||||
then:
|
||||
- hlk_fm22x.enroll:
|
||||
name: "Test"
|
||||
direction: 1
|
||||
- hlk_fm22x.delete_all:
|
||||
|
||||
uart:
|
||||
- id: uart_hlk_fm22x
|
||||
tx_pin: 4
|
||||
rx_pin: 5
|
||||
baud_rate: 115200
|
||||
|
||||
hlk_fm22x:
|
||||
on_face_scan_matched:
|
||||
- logger.log: test_hlk_22x_face_scan_matched
|
||||
on_face_scan_unmatched:
|
||||
- logger.log: test_hlk_22x_face_scan_unmatched
|
||||
on_face_scan_invalid:
|
||||
- logger.log: test_hlk_22x_face_scan_invalid
|
||||
on_face_info:
|
||||
- logger.log: test_hlk_22x_face_info
|
||||
on_enrollment_done:
|
||||
- logger.log: test_hlk_22x_enrollment_done
|
||||
on_enrollment_failed:
|
||||
- logger.log: test_hlk_22x_enrollment_failed
|
||||
|
||||
sensor:
|
||||
- platform: hlk_fm22x
|
||||
face_count:
|
||||
name: "Face Count"
|
||||
last_face_id:
|
||||
name: "Last Face ID"
|
||||
status:
|
||||
name: "Face Status"
|
||||
|
||||
binary_sensor:
|
||||
- platform: hlk_fm22x
|
||||
name: "Face Enrolling"
|
||||
|
||||
text_sensor:
|
||||
- platform: hlk_fm22x
|
||||
version:
|
||||
name: "HLK Version"
|
||||
last_face_name:
|
||||
name: "Last Face Name"
|
||||
47
tests/components/hlk_fm22x/test.rp2040-ard.yaml
Normal file
47
tests/components/hlk_fm22x/test.rp2040-ard.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
esphome:
|
||||
on_boot:
|
||||
then:
|
||||
- hlk_fm22x.enroll:
|
||||
name: "Test"
|
||||
direction: 1
|
||||
- hlk_fm22x.delete_all:
|
||||
|
||||
uart:
|
||||
- id: uart_hlk_fm22x
|
||||
tx_pin: 4
|
||||
rx_pin: 5
|
||||
baud_rate: 115200
|
||||
|
||||
hlk_fm22x:
|
||||
on_face_scan_matched:
|
||||
- logger.log: test_hlk_22x_face_scan_matched
|
||||
on_face_scan_unmatched:
|
||||
- logger.log: test_hlk_22x_face_scan_unmatched
|
||||
on_face_scan_invalid:
|
||||
- logger.log: test_hlk_22x_face_scan_invalid
|
||||
on_face_info:
|
||||
- logger.log: test_hlk_22x_face_info
|
||||
on_enrollment_done:
|
||||
- logger.log: test_hlk_22x_enrollment_done
|
||||
on_enrollment_failed:
|
||||
- logger.log: test_hlk_22x_enrollment_failed
|
||||
|
||||
sensor:
|
||||
- platform: hlk_fm22x
|
||||
face_count:
|
||||
name: "Face Count"
|
||||
last_face_id:
|
||||
name: "Last Face ID"
|
||||
status:
|
||||
name: "Face Status"
|
||||
|
||||
binary_sensor:
|
||||
- platform: hlk_fm22x
|
||||
name: "Face Enrolling"
|
||||
|
||||
text_sensor:
|
||||
- platform: hlk_fm22x
|
||||
version:
|
||||
name: "HLK Version"
|
||||
last_face_name:
|
||||
name: "Last Face Name"
|
||||
@@ -671,44 +671,50 @@ class TestEsphomeCore:
|
||||
os.environ.pop("ESPHOME_DATA_DIR", None)
|
||||
assert target.data_dir == Path(expected_default)
|
||||
|
||||
def test_platformio_cache_dir_with_env_var(self):
|
||||
"""Test platformio_cache_dir when PLATFORMIO_CACHE_DIR env var is set."""
|
||||
target = core.EsphomeCore()
|
||||
test_cache_dir = "/custom/cache/dir"
|
||||
def test_web_port__none(self, target):
|
||||
"""Test web_port returns None when web_server is not configured."""
|
||||
target.config = {}
|
||||
assert target.web_port is None
|
||||
|
||||
with patch.dict(os.environ, {"PLATFORMIO_CACHE_DIR": test_cache_dir}):
|
||||
assert target.platformio_cache_dir == test_cache_dir
|
||||
def test_web_port__explicit_web_server_default_port(self, target):
|
||||
"""Test web_port returns 80 when web_server is explicitly configured without port."""
|
||||
target.config = {const.CONF_WEB_SERVER: {}}
|
||||
assert target.web_port == 80
|
||||
|
||||
def test_platformio_cache_dir_without_env_var(self):
|
||||
"""Test platformio_cache_dir defaults to ~/.platformio/.cache."""
|
||||
target = core.EsphomeCore()
|
||||
def test_web_port__explicit_web_server_custom_port(self, target):
|
||||
"""Test web_port returns custom port when web_server is configured with port."""
|
||||
target.config = {const.CONF_WEB_SERVER: {const.CONF_PORT: 8080}}
|
||||
assert target.web_port == 8080
|
||||
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
# Ensure env var is not set
|
||||
os.environ.pop("PLATFORMIO_CACHE_DIR", None)
|
||||
expected = os.path.expanduser("~/.platformio/.cache")
|
||||
assert target.platformio_cache_dir == expected
|
||||
def test_web_port__ota_web_server_platform_only(self, target):
|
||||
"""
|
||||
Test web_port returns None when ota.web_server platform is explicitly configured.
|
||||
|
||||
def test_platformio_cache_dir_empty_env_var(self):
|
||||
"""Test platformio_cache_dir with empty env var falls back to default."""
|
||||
target = core.EsphomeCore()
|
||||
This is a critical test for Dashboard Issue #766:
|
||||
https://github.com/esphome/dashboard/issues/766
|
||||
|
||||
with patch.dict(os.environ, {"PLATFORMIO_CACHE_DIR": ""}):
|
||||
expected = os.path.expanduser("~/.platformio/.cache")
|
||||
assert target.platformio_cache_dir == expected
|
||||
When ota: platform: web_server is explicitly configured (or auto-loaded by captive_portal):
|
||||
- "web_server" appears in loaded_integrations (platform name added to integrations)
|
||||
- "ota/web_server" appears in loaded_platforms
|
||||
- But CONF_WEB_SERVER is NOT in config (only the platform is loaded, not the component)
|
||||
- web_port MUST return None (no web UI available)
|
||||
- Dashboard should NOT show VISIT button
|
||||
|
||||
def test_platformio_cache_dir_whitespace_env_var(self):
|
||||
"""Test platformio_cache_dir with whitespace-only env var falls back to default."""
|
||||
target = core.EsphomeCore()
|
||||
|
||||
with patch.dict(os.environ, {"PLATFORMIO_CACHE_DIR": " "}):
|
||||
expected = os.path.expanduser("~/.platformio/.cache")
|
||||
assert target.platformio_cache_dir == expected
|
||||
|
||||
def test_platformio_cache_dir_docker_addon_path(self):
|
||||
"""Test platformio_cache_dir in Docker/HA addon environment."""
|
||||
target = core.EsphomeCore()
|
||||
addon_cache = "/data/cache/platformio"
|
||||
|
||||
with patch.dict(os.environ, {"PLATFORMIO_CACHE_DIR": addon_cache}):
|
||||
assert target.platformio_cache_dir == addon_cache
|
||||
This test ensures web_port only checks CONF_WEB_SERVER in config, not loaded_integrations.
|
||||
"""
|
||||
# Simulate config with ota.web_server platform but no web_server component
|
||||
# This happens when:
|
||||
# 1. User explicitly configures: ota: - platform: web_server
|
||||
# 2. OR captive_portal auto-loads ota.web_server
|
||||
target.config = {
|
||||
const.CONF_OTA: [
|
||||
{
|
||||
"platform": "web_server",
|
||||
# OTA web_server platform config would be here
|
||||
}
|
||||
],
|
||||
# Note: CONF_WEB_SERVER is NOT in config - only the OTA platform
|
||||
}
|
||||
# Even though "web_server" is in loaded_integrations due to the platform,
|
||||
# web_port must return None because the full web_server component is not configured
|
||||
assert target.web_port is None
|
||||
|
||||
Reference in New Issue
Block a user