"""The tests for the Template automation."""
import pytest

from homeassistant.core import Context
from homeassistant.setup import async_setup_component
import homeassistant.components.automation as automation

from tests.common import (assert_setup_component, mock_component)
from tests.components.automation import common
from tests.common import async_mock_service


@pytest.fixture
def calls(hass):
    """Track calls to a mock serivce."""
    return async_mock_service(hass, 'test', 'automation')


@pytest.fixture(autouse=True)
def setup_comp(hass):
    """Initialize components."""
    mock_component(hass, 'group')
    hass.states.async_set('test.entity', 'hello')


async def test_if_fires_on_change_bool(hass, calls):
    """Test for firing on boolean change."""
    assert await async_setup_component(hass, automation.DOMAIN, {
        automation.DOMAIN: {
            'trigger': {
                'platform': 'template',
                'value_template': '{{ true }}',
            },