'Test extract entities function with entities stuff.'

def test_extract_entities_match_entities(self):

    self.assertListEqual(['device_tracker.phone_1'], template.extract_entities("\n{%    if    is_state('device_tracker.phone_1',    'home')    %}\n                Ha,    Hercules    is    home!\n{%    else    %}\n                Hercules    is    at    {{    states('device_tracker.phone_1')    }}.\n{%    endif    %}\n                                                "))
    self.assertListEqual(['binary_sensor.garage_door'], template.extract_entities('\n{{    as_timestamp(states.binary_sensor.garage_door.last_changed)    }}\n                                                '))
    self.assertListEqual(['binary_sensor.garage_door'], template.extract_entities('\n{{    states("binary_sensor.garage_door")    }}\n                                                '))
    self.assertListEqual(['device_tracker.phone_2'], template.extract_entities("\nis_state_attr('device_tracker.phone_2',    'battery',    40)\n                                                "))
    self.assertListEqual(sorted(['device_tracker.phone_1', 'device_tracker.phone_2']), sorted(template.extract_entities("\n{%    if    is_state('device_tracker.phone_1',    'home')    %}\n                Ha,    Hercules    is    home!\n{%    elif    states.device_tracker.phone_2.attributes.battery    <    40    %}\n                Hercules    you    power    goes    done!.\n{%    endif    %}\n                                                ")))
    self.assertListEqual(sorted(['sensor.pick_humidity', 'sensor.pick_temperature']), sorted(template.extract_entities('\n{{\n                states.sensor.pick_temperature.state    ~    \xe2\x80\x9e\xc2\xb0C    (\xe2\x80\x9c    ~\n                states.sensor.pick_humidity.state    ~    \xe2\x80\x9e    %\xe2\x80\x9c\n}}\n                                                ')))
    self.assertListEqual(sorted(['sensor.luftfeuchtigkeit_mean', 'input_slider.luftfeuchtigkeit']), sorted(template.extract_entities("{%    if    (states('sensor.luftfeuchtigkeit_mean')    |    int)    >    (states('input_slider.luftfeuchtigkeit')    |    int    +1.5)    %}true{%    endif    %}")))
