esphome/tests/component_tests/sensor/test_sensor.py
marecabo f95be6a0df
Device class attribute for sensor component (#1525)
* Add constants for sensor device_class

* Add device_class attribute to sensor component

* Add device_class attribute to sensor class

* Add device_class to mhz19 temperature sensor

* Add device_class to sensor in api component

* Add test for device_class of sensor

* Rename DEVICE_CLASS_NONE to DEVICE_CLASS_EMPTY for consistency

* Make optional attributes of sensor component truly optional
2021-02-15 12:49:02 -03:00

15 lines
374 B
Python

""" Tests for the sensor component """
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
assert "s_1->set_device_class(\"voltage\");" in main_cpp