#NEWLINE# def test_sending_mqtt_commands_and_optimistic( self ) : #NEWLINE# #INDENT# 'Test the sending MQTT commands in optimistic mode.' #NEWLINE# assert _setup_component ( self . hass , garage_door . DOMAIN , { #NEWLINE# #INDENT# garage_door . DOMAIN : { #NEWLINE# #INDENT# 'platform' : 'mqtt' , #NEWLINE# 'name' : 'test' , #NEWLINE# 'command_topic' : 'command-topic' , #NEWLINE# 'state_open' : 'beer state open' , #NEWLINE# 'state_closed' : 'beer state closed' , #NEWLINE# 'service_open' : 'beer open' , #NEWLINE# 'service_close' : 'beer close' , #NEWLINE# 'qos' : '2' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# state = self . hass . states . get ( 'garage_door.test' ) #NEWLINE# self . assertEqual ( STATE_CLOSED , state . state ) #NEWLINE# self . assertTrue ( state . attributes . get ( ATTR_ASSUMED_STATE ) ) #NEWLINE# garage_door . open_door ( self . hass , 'garage_door.test' ) #NEWLINE# self . hass . pool . block_till_done ( ) #NEWLINE# self . assertEqual ( ( 'command-topic' , 'beer open' , 2 , False ) , self . mock_publish . mock_calls [ ( - 1 ) ] [ 1 ] ) #NEWLINE# state = self . hass . states . get ( 'garage_door.test' ) #NEWLINE# self . assertEqual ( STATE_OPEN , state . state ) #NEWLINE# garage_door . close_door ( self . hass , 'garage_door.test' ) #NEWLINE# self . hass . pool . block_till_done ( ) #NEWLINE# self . assertEqual ( ( 'command-topic' , 'beer close' , 2 , False ) , self . mock_publish . mock_calls [ ( - 1 ) ] [ 1 ] ) #NEWLINE# state = self . hass . states . get ( 'garage_door.test' ) #NEWLINE# self . assertEqual ( STATE_CLOSED , state . state )