def test_variable_missing(caplog):
 caplog.set_level(logging.ERROR)
 with assert_setup_component(1):
  setup_component(HASS, sensor.DOMAIN, {sensor.DOMAIN: {'platform': 'pilight', 'name': 'test_3', 'variable': 'test', 'payload': {'protocol': 'test-protocol'}}})
  fire_pilight_message(protocol='test-protocol', data={'uuid': '1-2-3-4', 'other_variable': 3.141})
  HASS.block_till_done()
  logs = caplog.text
  assert ('No variable test in received code' in logs)

def test_variable_missing ( caplog ) : caplog . set_level ( logging . ERROR ) with assert_setup_component ( 1 ) : setup_component ( HASS , sensor . DOMAIN , { sensor . DOMAIN : { 'platform' : 'pilight' , 'name' : 'test_3' , 'variable' : 'test' , 'payload' : { 'protocol' : 'test-protocol' } } } ) fire_pilight_message ( protocol = 'test-protocol' , data = { 'uuid' : '1-2-3-4' , 'other_variable' : 3.141 } ) HASS . block_till_done ( ) logs = caplog . text assert ( 'No variable test in received code' in logs )
check if error message when variable missing .