mirror of
https://github.com/m5stack/esphome.git
synced 2026-05-20 11:52:52 -07:00
d0285cdc41
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
18 lines
509 B
Python
18 lines
509 B
Python
"""Tests for the sensor component."""
|
|
|
|
from tests.component_tests.helpers import extract_packed_value
|
|
|
|
|
|
def test_sensor_device_class_set(generate_main):
|
|
"""
|
|
When the device_class of sensor is set in the yaml file, it should be registered in main
|
|
"""
|
|
# Given
|
|
|
|
# When
|
|
main_cpp = generate_main("tests/component_tests/sensor/test_sensor.yaml")
|
|
|
|
# Then: device_class: voltage means packed value must be non-zero
|
|
packed = extract_packed_value(main_cpp, "s_1")
|
|
assert packed != 0
|