'Ensure image.send notification is sent on error.'

def test_image_send_notification_error(self):

    req = webob.Request.blank(('/images/%s' % UUID2))
    req.method = 'GET'
    req.remote_addr = '1.2.3.4'
    req.context = self.context
    image_meta = self.FIXTURE['image_meta']
    called = {'notified': False}
    expected_payload = {'bytes_sent': 17, 'image_id': UUID2, 'owner_id': image_meta['owner'], 'receiver_tenant_id': self.receiving_tenant, 'receiver_user_id': self.receiving_user, 'destination_ip': '1.2.3.4'}
    def fake_error(_event_type, _payload):
        self.assertEqual(expected_payload, _payload)
        called['notified'] = True
    self.stubs.Set(self.serializer.notifier, 'error', fake_error)
    glance.api.common.image_send_notification(17, 19, image_meta, req, self.serializer.notifier)
    self.assertTrue(called['notified'])
