diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-07-29 21:55:48 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-07-29 21:55:48 +0000 |
commit | 10fde8e5a61a1f0f0a1388b80a504c5a4290a96f (patch) | |
tree | 4bb7b44fb04c75d3c1998a82462614a7d5ae43eb /tests | |
parent | 6760289a077a0c39341de58d6bd3b639fffe4fa3 (diff) | |
parent | f976bbe697002367ff00a0588a3181fd42008e1c (diff) | |
download | keystone-10fde8e5a61a1f0f0a1388b80a504c5a4290a96f.tar.gz keystone-10fde8e5a61a1f0f0a1388b80a504c5a4290a96f.tar.xz keystone-10fde8e5a61a1f0f0a1388b80a504c5a4290a96f.zip |
Merge "Implement exception module i18n support"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_exception.py | 32 | ||||
-rw-r--r-- | tests/test_wsgi.py | 5 |
2 files changed, 25 insertions, 12 deletions
diff --git a/tests/test_exception.py b/tests/test_exception.py index 33250835..d442d572 100644 --- a/tests/test_exception.py +++ b/tests/test_exception.py @@ -67,14 +67,14 @@ class ExceptionTestCase(test.TestCase): attribute = uuid.uuid4().hex e = exception.ValidationError(target=target, attribute=attribute) self.assertValidJsonRendering(e) - self.assertIn(target, str(e)) - self.assertIn(attribute, str(e)) + self.assertIn(target, unicode(e)) + self.assertIn(attribute, unicode(e)) def test_not_found(self): target = uuid.uuid4().hex e = exception.NotFound(target=target) self.assertValidJsonRendering(e) - self.assertIn(target, str(e)) + self.assertIn(target, unicode(e)) def test_403_title(self): e = exception.Forbidden() @@ -101,7 +101,7 @@ class SecurityErrorTestCase(ExceptionTestCase): risky_info = uuid.uuid4().hex e = exception.Unauthorized(message=risky_info) self.assertValidJsonRendering(e) - self.assertNotIn(risky_info, str(e)) + self.assertNotIn(risky_info, unicode(e)) def test_unauthorized_exposure_in_debug(self): self.opt(debug=True) @@ -109,7 +109,7 @@ class SecurityErrorTestCase(ExceptionTestCase): risky_info = uuid.uuid4().hex e = exception.Unauthorized(message=risky_info) self.assertValidJsonRendering(e) - self.assertIn(risky_info, str(e)) + self.assertIn(risky_info, unicode(e)) def test_forbidden_exposure(self): self.opt(debug=False) @@ -117,7 +117,7 @@ class SecurityErrorTestCase(ExceptionTestCase): risky_info = uuid.uuid4().hex e = exception.Forbidden(message=risky_info) self.assertValidJsonRendering(e) - self.assertNotIn(risky_info, str(e)) + self.assertNotIn(risky_info, unicode(e)) def test_forbidden_exposure_in_debug(self): self.opt(debug=True) @@ -125,7 +125,7 @@ class SecurityErrorTestCase(ExceptionTestCase): risky_info = uuid.uuid4().hex e = exception.Forbidden(message=risky_info) self.assertValidJsonRendering(e) - self.assertIn(risky_info, str(e)) + self.assertIn(risky_info, unicode(e)) def test_forbidden_action_exposure(self): self.opt(debug=False) @@ -134,12 +134,12 @@ class SecurityErrorTestCase(ExceptionTestCase): action = uuid.uuid4().hex e = exception.ForbiddenAction(message=risky_info, action=action) self.assertValidJsonRendering(e) - self.assertNotIn(risky_info, str(e)) - self.assertIn(action, str(e)) + self.assertNotIn(risky_info, unicode(e)) + self.assertIn(action, unicode(e)) e = exception.ForbiddenAction(action=risky_info) self.assertValidJsonRendering(e) - self.assertIn(risky_info, str(e)) + self.assertIn(risky_info, unicode(e)) def test_forbidden_action_exposure_in_debug(self): self.opt(debug=True) @@ -148,8 +148,16 @@ class SecurityErrorTestCase(ExceptionTestCase): e = exception.ForbiddenAction(message=risky_info) self.assertValidJsonRendering(e) - self.assertIn(risky_info, str(e)) + self.assertIn(risky_info, unicode(e)) e = exception.ForbiddenAction(action=risky_info) self.assertValidJsonRendering(e) - self.assertIn(risky_info, str(e)) + self.assertIn(risky_info, unicode(e)) + + def test_unicode_argument_message(self): + self.opt(debug=False) + + risky_info = u'\u7ee7\u7eed\u884c\u7f29\u8fdb\u6216' + e = exception.Forbidden(message=risky_info) + self.assertValidJsonRendering(e) + self.assertNotIn(risky_info, unicode(e)) diff --git a/tests/test_wsgi.py b/tests/test_wsgi.py index 8ac594a8..369dd952 100644 --- a/tests/test_wsgi.py +++ b/tests/test_wsgi.py @@ -134,6 +134,11 @@ class ApplicationTest(BaseWSGITest): self.assertIn("testkey", app.kwargs) self.assertEquals("test", app.kwargs["testkey"]) + def test_render_exception(self): + e = exception.Unauthorized(message=u'\u7f51\u7edc') + resp = wsgi.render_exception(e) + self.assertEqual(resp.status_int, 401) + class ExtensionRouterTest(BaseWSGITest): def test_extensionrouter_local_config(self): |