core/tests/config/custom_components/light/test.py

27 lines
629 B
Python
Raw Normal View History

"""
2016-03-09 09:25:50 +00:00
Provide a mock switch platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.const import STATE_ON, STATE_OFF
2015-07-26 08:17:01 +00:00
from tests.common import MockToggleDevice
DEVICES = []
def init(empty=False):
2016-03-09 09:25:50 +00:00
"""Initalize the platform with devices."""
global DEVICES
DEVICES = [] if empty else [
MockToggleDevice('Ceiling', STATE_ON),
MockToggleDevice('Ceiling', STATE_OFF),
MockToggleDevice(None, STATE_OFF)
]
2015-01-20 05:39:24 +00:00
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
2016-03-09 09:25:50 +00:00
"""Return mock devices."""
2015-01-20 05:39:24 +00:00
add_devices_callback(DEVICES)