'Test the setting of the value via MQTT.'

def test_setting_sensor_value_via_mqtt_message(self):

    mock_component(self.hass, 'mqtt')
    assert setup_component(self.hass, sensor.DOMAIN, {sensor.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'test-topic', 'unit_of_measurement': 'fav    unit'}})
    fire_mqtt_message(self.hass, 'test-topic', '100')
    self.hass.block_till_done()
    state = self.hass.states.get('sensor.test')
    self.assertEqual('100', state.state)
    self.assertEqual('fav    unit', state.attributes.get('unit_of_measurement'))
