def test_receiver_get_not_found(self, mock_find): mock_find.side_effect = exc.ReceiverNotFound(receiver='RR') ex = self.assertRaises(rpc.ExpectedException, self.eng.receiver_get, self.ctx, 'Bogus') self.assertEqual(exc.ReceiverNotFound, ex.exc_info[0])
def test_webhook_trigger_receiver_not_found(self, mock_find): mock_find.side_effect = exception.ReceiverNotFound(receiver='RRR') ex = self.assertRaises(rpc.ExpectedException, self.eng.webhook_trigger, self.ctx, 'RRR') self.assertEqual(exception.ReceiverNotFound, ex.exc_info[0]) self.assertEqual('The receiver (RRR) could not be found.', six.text_type(ex.exc_info[1])) mock_find.assert_called_once_with(self.ctx, 'RRR')
def test_receiver_delete_not_found(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'delete', True) wid = 'aaaa-bbbb-cccc' req = self._delete('/receivers/%(receiver_id)s' % {'receiver_id': wid}) error = senlin_exc.ReceiverNotFound(receiver=wid) mock_call = self.patchobject(rpc_client.EngineClient, 'call') mock_call.side_effect = shared.to_remote_error(error) resp = shared.request_with_middleware(fault.FaultWrapper, self.controller.delete, req, receiver_id=wid) self.assertEqual(404, resp.json['code']) self.assertEqual('ReceiverNotFound', resp.json['error']['type'])
def load(cls, context, receiver_id=None, receiver_obj=None, project_safe=True): """Retrieve a receiver from database. :param context: the context for db operations. :param receiver_id: the unique ID of the receiver to retrieve. :param receiver_obj: the DB object of a receiver to retrieve. :param project_safe: Optional parameter specifying whether only receiver belong to the context.project will be loaded. """ if receiver_obj is None: receiver_obj = db_api.receiver_get(context, receiver_id, project_safe=project_safe) if receiver_obj is None: raise exception.ReceiverNotFound(receiver=receiver_id) return cls._from_db_record(receiver_obj)