def test_config_google_home_entity_id_to_number():
 conf = Config(Mock(), {'type': 'google_home'})
 mop = mock_open(read_data=json.dumps({'1': 'light.test2'}))
 handle = mop()
 with patch('homeassistant.components.emulated_hue.open', mop, create=True):
  number = conf.entity_id_to_number('light.test')
  assert (number == '2')
  assert (handle.write.call_count == 1)
  assert (json.loads(handle.write.mock_calls[0][1][0]) == {'1': 'light.test2', '2': 'light.test'})
  number = conf.entity_id_to_number('light.test')
  assert (number == '2')
  assert (handle.write.call_count == 1)
  number = conf.entity_id_to_number('light.test2')
  assert (number == '1')
  assert (handle.write.call_count == 1)
  entity_id = conf.number_to_entity_id('1')
  assert (entity_id == 'light.test2')

def test_config_google_home_entity_id_to_number ( ) : conf = Config ( Mock ( ) , { 'type' : 'google_home' } ) mop = mock_open ( read_data = json . dumps ( { '1' : 'light.test2' } ) ) handle = mop ( ) with patch ( 'homeassistant.components.emulated_hue.open' , mop , create = True ) : number = conf . entity_id_to_number ( 'light.test' ) assert ( number == '2' ) assert ( handle . write . call_count == 1 ) assert ( json . loads ( handle . write . mock_calls [ 0 ] [ 1 ] [ 0 ] ) == { '1' : 'light.test2' , '2' : 'light.test' } ) number = conf . entity_id_to_number ( 'light.test' ) assert ( number == '2' ) assert ( handle . write . call_count == 1 ) number = conf . entity_id_to_number ( 'light.test2' ) assert ( number == '1' ) assert ( handle . write . call_count == 1 ) entity_id = conf . number_to_entity_id ( '1' ) assert ( entity_id == 'light.test2' )
test config adheres to the type .