Ensure lazy translation is disabled properly

Commit 894f20d9cf57b36ccf9a675c6b2b070d56c9b297 changed the way that
enable_lazy() is being configured in cinder's test cases.  The changes
were required to remove the use of _lazy from the oslo's i18n library.
_lazy was removed from i18n and the code that was accessing the internal
variable broke.  The commit referenced above made changes to remove
the use of _lazy.

The commit, however, changed the behavior of the test cases to only
enable_lazy without disabling it, which diverges from the original
behavior.

This commit uses the new oslo.i18n ToggleLazy fixture (added in 1.3.0).

Closes-bug: 1408099
Change-Id: If9530b2bb8f0f511ccff4527ea9f2d13f7103bdb
This commit is contained in:
Jay S. Bryant 2015-01-12 22:55:45 -06:00
parent 7512734c80
commit 5be6971908
2 changed files with 4 additions and 12 deletions

View File

@ -17,11 +17,11 @@ from xml.dom import minidom
import mock
from oslo.serialization import jsonutils
from oslo_i18n import fixture as i18n_fixture
import webob.dec
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import i18n as cinder_i18n
from cinder.i18n import _
from cinder import test
@ -31,8 +31,7 @@ class TestFaults(test.TestCase):
def setUp(self):
super(TestFaults, self).setUp()
cinder_i18n.enable_lazy()
self.addCleanup(cinder_i18n.enable_lazy())
self.useFixture(i18n_fixture.ToggleLazy(True))
def _prepare_xml(self, xml_string):
"""Remove characters from string which hinder XML equality testing."""
@ -41,7 +40,6 @@ class TestFaults(test.TestCase):
xml_string = xml_string.replace("\t", "")
return xml_string
@test.testtools.skip("SKIP until bug #1408099 is fixed")
def test_400_fault_json(self):
"""Test fault serialized to JSON via file-extension and/or header."""
requests = [
@ -64,7 +62,6 @@ class TestFaults(test.TestCase):
self.assertEqual(response.content_type, "application/json")
self.assertEqual(expected, actual)
@test.testtools.skip("SKIP until bug #1408099 is fixed")
def test_413_fault_json(self):
"""Test fault serialized to JSON via file-extension and/or header."""
requests = [
@ -90,7 +87,6 @@ class TestFaults(test.TestCase):
self.assertEqual(response.content_type, "application/json")
self.assertEqual(expected, actual)
@test.testtools.skip("SKIP until bug #1408099 is fixed")
def test_raise(self):
"""Ensure the ability to raise :class:`Fault` in WSGI-ified methods."""
@webob.dec.wsgify
@ -103,7 +99,6 @@ class TestFaults(test.TestCase):
self.assertEqual(resp.status_int, 404)
self.assertIn('whut?', resp.body)
@test.testtools.skip("SKIP until bug #1408099 is fixed")
def test_raise_403(self):
"""Ensure the ability to raise :class:`Fault` in WSGI-ified methods."""
@webob.dec.wsgify
@ -117,7 +112,6 @@ class TestFaults(test.TestCase):
self.assertNotIn('resizeNotAllowed', resp.body)
self.assertIn('forbidden', resp.body)
@test.testtools.skip("SKIP until bug #1408099 is fixed")
@mock.patch('cinder.api.openstack.wsgi.i18n.translate')
def test_raise_http_with_localized_explanation(self, mock_translate):
params = ('blah', )
@ -139,13 +133,11 @@ class TestFaults(test.TestCase):
self.assertIn(("Mensaje traducido"), resp.body)
self.stubs.UnsetAll()
@test.testtools.skip("SKIP until bug #1408099 is fixed")
def test_fault_has_status_int(self):
"""Ensure the status_int is set correctly on faults."""
fault = wsgi.Fault(webob.exc.HTTPBadRequest(explanation='what?'))
self.assertEqual(fault.status_int, 400)
@test.testtools.skip("SKIP until bug #1408099 is fixed")
def test_xml_serializer(self):
"""Ensure that a v2 request responds with a v2 xmlns."""
request = webob.Request.blank('/v2',

View File

@ -26,12 +26,12 @@ import urllib2
import mock
from oslo_config import cfg
from oslo_i18n import fixture as i18n_fixture
import testtools
import webob
import webob.dec
from cinder import exception
from cinder import i18n
from cinder.i18n import _
from cinder import test
import cinder.wsgi
@ -267,7 +267,7 @@ class ExceptionTest(test.TestCase):
def setUp(self):
super(ExceptionTest, self).setUp()
i18n.enable_lazy()
self.useFixture(i18n_fixture.ToggleLazy(True))
def _wsgi_app(self, inner_app):
# NOTE(luisg): In order to test localization, we need to