'Test emails from allowed sender.'

def test_allowed_sender(self):

    test_message = email.message.Message()
    test_message['From'] = 'sender@test.com'
    test_message['Subject'] = 'Test'
    test_message['Date'] = datetime.datetime(2016, 1, 1, 12, 44, 57)
    test_message.set_payload('Test    Message')
    sensor = imap_email_content.EmailContentSensor(self.hass, FakeEMailReader(deque([test_message])), 'test_emails_sensor', ['sender@test.com'], None)
    sensor.entity_id = 'sensor.emailtest'
    sensor.schedule_update_ha_state(True)
    self.hass.block_till_done()
    self.assertEqual('Test    Message', sensor.state)
    self.assertEqual('sender@test.com', sensor.device_state_attributes['from'])
    self.assertEqual('Test', sensor.device_state_attributes['subject'])
    self.assertEqual(datetime.datetime(2016, 1, 1, 12, 44, 57), sensor.device_state_attributes['date'])
