mirror of
https://github.com/esphome/esphome.git
synced 2025-08-14 10:09:34 +01:00
.ai
.devcontainer
.github
.vscode
docker
esphome
script
tests
component_tests
components
dashboard
integration
fixtures
README.md
__init__.py
conftest.py
const.py
test_api_conditional_memory.py
test_api_custom_services.py
test_api_homeassistant.py
test_api_message_size_batching.py
test_api_reboot_timeout.py
test_api_string_lambda.py
test_api_vv_logging.py
test_areas_and_devices.py
test_automations.py
test_batch_delay_zero_rapid_transitions.py
test_device_id_in_state.py
test_duplicate_entities.py
test_entity_icon.py
test_gpio_expander_cache.py
test_host_mode_api_password.py
test_host_mode_basic.py
test_host_mode_batch_delay.py
test_host_mode_empty_string_options.py
test_host_mode_entity_fields.py
test_host_mode_fan_preset.py
test_host_mode_many_entities.py
test_host_mode_many_entities_multiple_connections.py
test_host_mode_noise_encryption.py
test_host_mode_reconnect.py
test_host_mode_sensor.py
test_large_message_batching.py
test_legacy_area.py
test_light_calls.py
test_loop_disable_enable.py
test_runtime_stats.py
test_scheduler_bulk_cleanup.py
test_scheduler_defer_cancel.py
test_scheduler_defer_cancel_regular.py
test_scheduler_defer_fifo_simple.py
test_scheduler_defer_stress.py
test_scheduler_heap_stress.py
test_scheduler_null_name.py
test_scheduler_rapid_cancellation.py
test_scheduler_recursive_timeout.py
test_scheduler_retry_test.py
test_scheduler_simultaneous_callbacks.py
test_scheduler_string_lifetime.py
test_scheduler_string_name_stress.py
test_scheduler_string_test.py
types.py
script
test_build_components
test_packages
unit_tests
.gitignore
README.md
__init__.py
custom.h
dummy_main.cpp
pnglogo.png
.clang-format
.clang-tidy
.clang-tidy.hash
.coveragerc
.dockerignore
.editorconfig
.flake8
.gitattributes
.gitignore
.pre-commit-config.yaml
.yamllint
CLAUDE.md
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Doxyfile
GEMINI.md
LICENSE
MANIFEST.in
README.md
netlify.toml
platformio.ini
pyproject.toml
requirements.txt
requirements_dev.txt
requirements_test.txt
sdkconfig.defaults
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
"""Integration test for API handling of large messages exceeding batch size."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from aioesphomeapi import SelectInfo
|
|
import pytest
|
|
|
|
from .types import APIClientConnectedFactory, RunCompiledFunction
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_large_message_batching(
|
|
yaml_config: str,
|
|
run_compiled: RunCompiledFunction,
|
|
api_client_connected: APIClientConnectedFactory,
|
|
) -> None:
|
|
"""Test API can handle large messages (>1390 bytes) in batches."""
|
|
# Write, compile and run the ESPHome device, then connect to API
|
|
async with run_compiled(yaml_config), api_client_connected() as client:
|
|
# Verify we can get device info
|
|
device_info = await client.device_info()
|
|
assert device_info is not None
|
|
assert device_info.name == "large-message-test"
|
|
|
|
# List entities - this will include our select with many options
|
|
entity_info, services = await client.list_entities_services()
|
|
|
|
# Find our large select entity
|
|
large_select = None
|
|
for entity in entity_info:
|
|
if isinstance(entity, SelectInfo) and entity.object_id == "large_select":
|
|
large_select = entity
|
|
break
|
|
|
|
assert large_select is not None, "Could not find large_select entity"
|
|
|
|
# Verify the select has all its options
|
|
# We created 100 options with long names
|
|
assert len(large_select.options) == 100, (
|
|
f"Expected 100 options, got {len(large_select.options)}"
|
|
)
|
|
|
|
# Verify all options are present and correct
|
|
for i in range(100):
|
|
expected_option = f"Option {i:03d} - This is a very long option name to make the message larger than the typical batch size of 1390 bytes"
|
|
assert expected_option in large_select.options, (
|
|
f"Missing option: {expected_option}"
|
|
)
|
|
|
|
# Also verify we can still receive other entities in the same batch
|
|
# Count total entities - should have at least our select plus some sensors
|
|
entity_count = len(entity_info)
|
|
assert entity_count >= 4, f"Expected at least 4 entities, got {entity_count}"
|
|
|
|
# Verify we have different entity types (not just selects)
|
|
entity_types = {type(entity).__name__ for entity in entity_info}
|
|
assert len(entity_types) >= 2, (
|
|
f"Expected multiple entity types, got {entity_types}"
|
|
)
|