NaNJSONEncoder should be used in api "cinder/tenantabsolutelimits"
In api "cinder/tenantabsolutelimits", result maybe contains Infinity values, but Infinity values are not supported by JSON standard, so NaNJSONEncoder is needed here. Change-Id: I750637e3214ad46a8b29e1ad565870cdcb827fe1 Closes-bug: #1714417 (cherry picked from commitde37fc1024
) (cherry picked from commit2cda101cf9
)
This commit is contained in:
parent
2ee37e5ad1
commit
4f1b2520cc
|
@ -18,6 +18,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from django.views import generic
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.api.rest import json_encoder
|
||||
from openstack_dashboard.api.rest import urls
|
||||
from openstack_dashboard.api.rest import utils as rest_utils
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
@ -317,7 +318,7 @@ class QoSSpecs(generic.View):
|
|||
class TenantAbsoluteLimits(generic.View):
|
||||
url_regex = r'cinder/tenantabsolutelimits/$'
|
||||
|
||||
@rest_utils.ajax()
|
||||
@rest_utils.ajax(json_encoder=json_encoder.NaNJSONEncoder)
|
||||
def get(self, request):
|
||||
return api.cinder.tenant_absolute_limits(request)
|
||||
|
||||
|
|
|
@ -290,10 +290,12 @@ class CinderRestTestCase(test.TestCase):
|
|||
def test_tenant_absolute_limits_get(self, cc):
|
||||
request = self.mock_rest_request(GET={})
|
||||
cc.tenant_absolute_limits.return_value = \
|
||||
{'id': 'one'}
|
||||
{'id': 'one', 'val': float('inf')}
|
||||
response = cinder.TenantAbsoluteLimits().get(request)
|
||||
self.assertStatusCode(response, 200)
|
||||
self.assertEqual(response.content.decode("utf-8"), '{"id": "one"}')
|
||||
response_as_json = json.loads(response.content.decode('utf-8'))
|
||||
self.assertEqual(response_as_json['id'], 'one')
|
||||
self.assertEqual(response_as_json['val'], 1e+999)
|
||||
cc.tenant_absolute_limits.assert_called_once_with(request)
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue