Exemplo n.º 1
0
async def test_device_media_player(hass, device_class, google_type):
    """Test that a binary entity syncs to the correct device type."""
    sensor = AbstractDemoPlayer("Demo", device_class=device_class)
    sensor.hass = hass
    sensor.entity_id = "media_player.demo"
    await sensor.async_update_ha_state()

    result = await sh.async_handle_message(
        hass,
        BASIC_CONFIG,
        "test-agent",
        {"requestId": REQ_ID, "inputs": [{"intent": "action.devices.SYNC"}]},
    )

    assert result == {
        "requestId": REQ_ID,
        "payload": {
            "agentUserId": "test-agent",
            "devices": [
                {
                    "attributes": {},
                    "id": sensor.entity_id,
                    "name": {"name": sensor.name},
                    "traits": ["action.devices.traits.OnOff"],
                    "type": google_type,
                    "willReportState": False,
                }
            ],
        },
    }
async def test_device_media_player(hass, device_class, google_type):
    """Test that a binary entity syncs to the correct device type."""
    sensor = AbstractDemoPlayer('Demo', device_class=device_class)
    sensor.hass = hass
    sensor.entity_id = 'media_player.demo'
    await sensor.async_update_ha_state()

    result = await sh.async_handle_message(
        hass, BASIC_CONFIG, 'test-agent', {
            "requestId": REQ_ID,
            "inputs": [{
                "intent": "action.devices.SYNC"
            }]
        })

    assert result == {
        'requestId': REQ_ID,
        'payload': {
            'agentUserId':
            'test-agent',
            'devices': [{
                'attributes': {},
                'id': sensor.entity_id,
                'name': {
                    'name': sensor.name
                },
                'traits': ['action.devices.traits.OnOff'],
                'type': google_type,
                'willReportState': False
            }]
        }
    }