Replace standard json module with openstack.common.jsonutils
Implements blueprint use-common-jsonutils 1. Edit openstack-common.conf and import nova/openstack/common/jsonutils.py 2. Remove json package imports and replace with jsonutils Places where using json.load hasn't changed. Change-Id: Ie6feab605fb0474fd505c56ef57b7a9ecfa5269d
This commit is contained in:
@@ -13,12 +13,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import webob
|
||||
|
||||
from nova import compute
|
||||
from nova import exception
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova import test
|
||||
from nova.tests.api.openstack import fakes
|
||||
|
||||
@@ -56,11 +55,11 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
body = {'os-getConsoleOutput': {}}
|
||||
req = webob.Request.blank('/v2/fake/servers/1/action')
|
||||
req.method = "POST"
|
||||
req.body = json.dumps(body)
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
output = json.loads(res.body)
|
||||
output = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(output, {'output': '0\n1\n2\n3\n4'})
|
||||
|
||||
@@ -68,10 +67,10 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
body = {'os-getConsoleOutput': {'length': 3}}
|
||||
req = webob.Request.blank('/v2/fake/servers/1/action')
|
||||
req.method = "POST"
|
||||
req.body = json.dumps(body)
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
output = json.loads(res.body)
|
||||
output = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(output, {'output': '2\n3\n4'})
|
||||
|
||||
@@ -80,7 +79,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
body = {'os-getConsoleOutput': {}}
|
||||
req = webob.Request.blank('/v2/fake/servers/1/action')
|
||||
req.method = "POST"
|
||||
req.body = json.dumps(body)
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
@@ -91,7 +90,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
body = {'os-getConsoleOutput': {}}
|
||||
req = webob.Request.blank('/v2/fake/servers/1/action')
|
||||
req.method = "POST"
|
||||
req.body = json.dumps(body)
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
@@ -101,7 +100,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
body = {}
|
||||
req = webob.Request.blank('/v2/fake/servers/1/action')
|
||||
req.method = "POST"
|
||||
req.body = json.dumps(body)
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
|
Reference in New Issue
Block a user