Update json module to jsonutils

oslo project provide jsonutils, and the others use it in many place,
this PS to update the json module to oslo jsonutils for consistency.

Change-Id: Ie8bdc41e420fbbbafaca7d7eaeaa702d93c6a18d
This commit is contained in:
cao.yuan 2019-02-24 22:45:07 +08:00 committed by Eyal
parent d1b2092c8f
commit 378083e91e
4 changed files with 12 additions and 11 deletions

View File

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from oslo_log import log as logging
from oslo_serialization import jsonutils
from testtools import matchers
from vitrage_tempest_plugin.tests.base import BaseVitrageTempest
@ -70,7 +69,7 @@ class BaseRcaTest(BaseVitrageTempest):
LOG.debug("The rca taken from cli is : %s", cli_rca)
LOG.debug("The rca taken by api is : %s", api_rca)
parsed_rca = json.loads(cli_rca)
parsed_rca = jsonutils.loads(cli_rca)
sorted_cli_graph = self._clean_timestamps(sorted(parsed_rca.items()))
sorted_api_graph = self._clean_timestamps(sorted(api_rca.items()))
self.assert_list_equal(sorted_cli_graph, sorted_api_graph)

View File

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from oslo_log import log as logging
from oslo_serialization import jsonutils
from testtools import matchers
from vitrage_tempest_plugin.tests.base import BaseVitrageTempest
@ -172,7 +171,7 @@ class TestResource(BaseVitrageTempest):
'The resources taken from rest api is empty')
sorted_cli_resources = sorted(
json.loads(cli_resources),
jsonutils.loads(cli_resources),
key=lambda resource: resource["ID"])
sorted_api_resources = sorted(
api_resources,

View File

@ -11,9 +11,12 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
import random
import time
from oslo_serialization import jsonutils
from vitrage_tempest_plugin.tests.common.constants import AodhProperties as \
AodhProps
from vitrage_tempest_plugin.tests.common.tempest_clients import TempestClients
@ -125,7 +128,7 @@ def _aodh_request(type, resource_id=None, name=None, rule=None):
# alarms, update accordingly
query[0].update(dict(field='resource_id'))
rule[AodhProps.RESOURCES_THRESHOLD_RULE].update(dict(
query=json.dumps(query)))
query=jsonutils.dump_as_bytes(query)))
request.update(rule)
return request

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import time
from oslo_log import log as logging
from oslo_serialization import jsonutils
from testtools.matchers import HasLength
from vitrage_tempest_plugin.tests.api.event.base import BaseTestEvents
@ -140,7 +140,7 @@ class TestMistralNotifier(BaseTestEvents):
# are at the end. Check the last `num_instances` executions.
execution = \
self.mistral_client.executions.get(executions[-i].id)
execution_input = json.loads(execution.input)
execution_input = jsonutils.loads(execution.input)
executed_on_instances.add(execution_input['farewell'])
msg = "There are %d instances in the graph but only %d distinct " \
@ -160,7 +160,7 @@ class TestMistralNotifier(BaseTestEvents):
'The last execution had no input')
self.assertIn('farewell', execution_input_str,
'No \'farewell\' key in the last execution input')
execution_input = json.loads(execution_input_str)
execution_input = jsonutils.loads(execution_input_str)
farewell_value = execution_input['farewell']
self.assertIsNotNone(farewell_value, '\'farewell\' input parameter is '
'None in last workflow execution')