示例#1
0
def test_request_data():
    """Test request data properties."""
    config = MockConfig()
    data = helpers.RequestData(config, "test_user", SOURCE_LOCAL,
                               "test_request_id", None)
    assert data.is_local_request is True

    data = helpers.RequestData(config, "test_user", SOURCE_CLOUD,
                               "test_request_id", None)
    assert data.is_local_request is False
示例#2
0
from homeassistant.const import (STATE_ON, STATE_OFF, ATTR_ENTITY_ID,
                                 SERVICE_TURN_ON, SERVICE_TURN_OFF,
                                 TEMP_CELSIUS, TEMP_FAHRENHEIT,
                                 ATTR_SUPPORTED_FEATURES, ATTR_TEMPERATURE,
                                 ATTR_DEVICE_CLASS, ATTR_ASSUMED_STATE,
                                 STATE_UNKNOWN)
from homeassistant.core import State, DOMAIN as HA_DOMAIN, EVENT_CALL_SERVICE
from homeassistant.util import color
from tests.common import async_mock_service, mock_coro
from . import BASIC_CONFIG, MockConfig

REQ_ID = 'ff36a3cc-ec34-11e6-b1a0-64510650abcf'

BASIC_DATA = helpers.RequestData(
    BASIC_CONFIG,
    'test-agent',
    REQ_ID,
)

PIN_CONFIG = MockConfig(secure_devices_pin='1234')

PIN_DATA = helpers.RequestData(
    PIN_CONFIG,
    'test-agent',
    REQ_ID,
)


async def test_brightness_light(hass):
    """Test brightness trait support for light domain."""
    assert helpers.get_google_type(light.DOMAIN, None) is not None
示例#3
0
    TEMP_CELSIUS,
    TEMP_FAHRENHEIT,
    ATTR_SUPPORTED_FEATURES,
    ATTR_TEMPERATURE,
    ATTR_DEVICE_CLASS,
    ATTR_ASSUMED_STATE,
    STATE_UNKNOWN,
)
from homeassistant.core import State, DOMAIN as HA_DOMAIN, EVENT_CALL_SERVICE
from homeassistant.util import color
from tests.common import async_mock_service, mock_coro
from . import BASIC_CONFIG, MockConfig

REQ_ID = "ff36a3cc-ec34-11e6-b1a0-64510650abcf"

BASIC_DATA = helpers.RequestData(BASIC_CONFIG, "test-agent", REQ_ID)

PIN_CONFIG = MockConfig(secure_devices_pin="1234")

PIN_DATA = helpers.RequestData(PIN_CONFIG, "test-agent", REQ_ID)


async def test_brightness_light(hass):
    """Test brightness trait support for light domain."""
    assert helpers.get_google_type(light.DOMAIN, None) is not None
    assert trait.BrightnessTrait.supported(light.DOMAIN,
                                           light.SUPPORT_BRIGHTNESS, None)

    trt = trait.BrightnessTrait(
        hass,
        State("light.bla", light.STATE_ON, {light.ATTR_BRIGHTNESS: 243}),