Ejemplo n.º 1
0
    def test_safe_exception_translated(self, mock_translate):
        msg = gettextutils.Message('Should be translated.', domain='nova')
        safe_exception = exception.NotFound()
        safe_exception.msg_fmt = msg
        safe_exception.safe = True
        safe_exception.code = 404

        req = webob.Request.blank('/')

        def fake_translate(mesg, locale):
            if mesg == "Should be translated.":
                return "I've been translated!"
            return mesg

        mock_translate.side_effect = fake_translate

        def raiser(*args, **kwargs):
            raise safe_exception

        wrapper = nova.api.openstack.FaultWrapper(raiser)
        response = req.get_response(wrapper)

        self.assertIn("I've been translated!", unicode(response.body))
        mock_translate.assert_any_call(u'Should be translated.', None)
Ejemplo n.º 2
0
 class FakeNovaException(exception.NovaException):
     msg_fmt = gettextutils.Message("Some message %(param)s", 'nova')