def test_sending_mqtt_commands_and_optimistic(self): """Test the sending MQTT commands in optimistic mode.""" with assert_setup_component(1): assert setup_component(self.hass, garage_door.DOMAIN, { garage_door.DOMAIN: { 'platform': 'mqtt', 'name': 'test', 'command_topic': 'command-topic', 'state_open': 'beer state open', 'state_closed': 'beer state closed', 'service_open': 'beer open', 'service_close': 'beer close', 'qos': '2' } }) state = self.hass.states.get('garage_door.test') self.assertEqual(STATE_CLOSED, state.state) self.assertTrue(state.attributes.get(ATTR_ASSUMED_STATE)) garage_door.open_door(self.hass, 'garage_door.test') self.hass.block_till_done() self.assertEqual(('command-topic', 'beer open', 2, False), self.mock_publish.mock_calls[-1][1]) state = self.hass.states.get('garage_door.test') self.assertEqual(STATE_OPEN, state.state) garage_door.close_door(self.hass, 'garage_door.test') self.hass.block_till_done() self.assertEqual(('command-topic', 'beer close', 2, False), self.mock_publish.mock_calls[-1][1]) state = self.hass.states.get('garage_door.test') self.assertEqual(STATE_CLOSED, state.state)
def test_sending_mqtt_commands_and_optimistic(self): """Test the sending MQTT commands in optimistic mode.""" assert _setup_component( self.hass, garage_door.DOMAIN, { garage_door.DOMAIN: { 'platform': 'mqtt', 'name': 'test', 'command_topic': 'command-topic', 'state_open': 'beer state open', 'state_closed': 'beer state closed', 'service_open': 'beer open', 'service_close': 'beer close', 'qos': '2' } }) state = self.hass.states.get('garage_door.test') self.assertEqual(STATE_CLOSED, state.state) self.assertTrue(state.attributes.get(ATTR_ASSUMED_STATE)) garage_door.open_door(self.hass, 'garage_door.test') self.hass.pool.block_till_done() self.assertEqual(('command-topic', 'beer open', 2, False), self.mock_publish.mock_calls[-1][1]) state = self.hass.states.get('garage_door.test') self.assertEqual(STATE_OPEN, state.state) garage_door.close_door(self.hass, 'garage_door.test') self.hass.pool.block_till_done() self.assertEqual(('command-topic', 'beer close', 2, False), self.mock_publish.mock_calls[-1][1]) state = self.hass.states.get('garage_door.test') self.assertEqual(STATE_CLOSED, state.state)
def test_open_door(self): """Test opeing of the door.""" gd.open_door(self.hass, LEFT) self.hass.pool.block_till_done() self.assertFalse(gd.is_closed(self.hass, LEFT))
def test_open_door(self): gd.open_door(self.hass, LEFT) self.hass.pool.block_till_done() self.assertFalse(gd.is_closed(self.hass, LEFT))