'Test changing state optimistically.'

def test_optimistic_state_change(self):

    self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'command_topic': 'command-topic', 'qos': 0}}))
    state = self.hass.states.get('cover.test')
    self.assertEqual(STATE_UNKNOWN, state.state)
    cover.open_cover(self.hass, 'cover.test')
    self.hass.block_till_done()
    self.assertEqual(('command-topic', 'OPEN', 0, False), self.mock_publish.mock_calls[(-2)][1])
    state = self.hass.states.get('cover.test')
    self.assertEqual(STATE_OPEN, state.state)
    cover.close_cover(self.hass, 'cover.test')
    self.hass.block_till_done()
    self.assertEqual(('command-topic', 'CLOSE', 0, False), self.mock_publish.mock_calls[(-2)][1])
    state = self.hass.states.get('cover.test')
    self.assertEqual(STATE_CLOSED, state.state)
