'Test for firing if contition is on.'

def test_if_fires_on_for_condition(self):

    point1 = dt_util.utcnow()
    point2 = (point1 + timedelta(seconds=10))
    with patch('homeassistant.core.dt_util.utcnow') as mock_utcnow:
        mock_utcnow.return_value = point1
        self.hass.states.set('test.entity', 'on')
        assert setup_component(self.hass, automation.DOMAIN, {automation.DOMAIN: {'trigger': {'platform': 'event', 'event_type': 'test_event'}, 'condition': {'condition': 'state', 'entity_id': 'test.entity', 'state': 'on', 'for': {'seconds': 5}}, 'action': {'service': 'test.automation'}}})
        self.hass.bus.fire('test_event')
        self.hass.block_till_done()
        self.assertEqual(0, len(self.calls))
        mock_utcnow.return_value = point2
        self.hass.bus.fire('test_event')
        self.hass.block_till_done()
        self.assertEqual(1, len(self.calls))
