'Test the controlling state via topic.'

def test_controlling_state_via_topic(self):

    assert setup_component(self.hass, lock.DOMAIN, {lock.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'payload_lock': 'LOCK', 'payload_unlock': 'UNLOCK'}})
    state = self.hass.states.get('lock.test')
    self.assertEqual(STATE_UNLOCKED, state.state)
    self.assertFalse(state.attributes.get(ATTR_ASSUMED_STATE))
    fire_mqtt_message(self.hass, 'state-topic', 'LOCK')
    self.hass.block_till_done()
    state = self.hass.states.get('lock.test')
    self.assertEqual(STATE_LOCKED, state.state)
    fire_mqtt_message(self.hass, 'state-topic', 'UNLOCK')
    self.hass.block_till_done()
    state = self.hass.states.get('lock.test')
    self.assertEqual(STATE_UNLOCKED, state.state)
