'Test updating an existing device.'

@patch('apns2.client.APNsClient')
def test_send_with_state(self, mock_client):

    send = mock_client.return_value.send_notification
    yaml_file = {1234: {'name': 'test    device    1', 'tracking_device_id': 'tracking123'}, 5678: {'name': 'test    device    2', 'tracking_device_id': 'tracking456'}}
    with patch('homeassistant.components.notify.apns.load_yaml_config_file', Mock(return_value=yaml_file)):
        with patch('os.path.isfile', Mock(return_value=True)):
            notify_service = apns.ApnsNotificationService(self.hass, 'test_app', 'testapp.appname', False, 'test_app.pem')
    notify_service.device_state_changed_listener('device_tracker.tracking456', State('device_tracker.tracking456', None), State('device_tracker.tracking456', 'home'))
    notify_service.send_message(message='Hello', target='home')
    self.assertTrue(send.called)
    self.assertEqual(1, len(send.mock_calls))
    target = send.mock_calls[0][1][0]
    payload = send.mock_calls[0][1][1]
    self.assertEqual('5678', target)
    self.assertEqual('Hello', payload.alert)
