mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 03:12:20 +01:00
Bug/fix internal flag in binary sensor (#1136)
This commit is contained in:
24
tests/component_tests/binary_sensor/test_binary_sensor.py
Normal file
24
tests/component_tests/binary_sensor/test_binary_sensor.py
Normal file
@@ -0,0 +1,24 @@
|
||||
""" Tests for the binary sensor component """
|
||||
|
||||
from esphome.core import CORE
|
||||
from esphome.config import read_config
|
||||
from esphome.__main__ import generate_cpp_contents
|
||||
|
||||
|
||||
def test_binary_sensor_config_value_internal_set():
|
||||
"""
|
||||
Test that the "internal" config value is correctly set
|
||||
"""
|
||||
# Given
|
||||
CORE.config_path = "tests/component_tests/binary_sensor/test_binary_sensor.yaml"
|
||||
CORE.config = read_config({})
|
||||
|
||||
# When
|
||||
generate_cpp_contents(CORE.config)
|
||||
# print(CORE.cpp_main_section)
|
||||
|
||||
# Then
|
||||
assert "bs_1->set_internal(true);" in CORE.cpp_main_section
|
||||
assert "bs_2->set_internal(false);" in CORE.cpp_main_section
|
||||
|
||||
CORE.reset()
|
18
tests/component_tests/binary_sensor/test_binary_sensor.yaml
Normal file
18
tests/component_tests/binary_sensor/test_binary_sensor.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
esphome:
|
||||
name: test
|
||||
platform: ESP8266
|
||||
board: d1_mini_lite
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
id: bs_1
|
||||
name: "test bs1"
|
||||
internal: true
|
||||
pin:
|
||||
number: D0
|
||||
- platform: gpio
|
||||
id: bs_2
|
||||
name: "test bs2"
|
||||
internal: false
|
||||
pin:
|
||||
number: D1
|
Reference in New Issue
Block a user