Py3: Switch json to oslo_serialization
It is still using json.loads()/dumps() in the test_impl_kafka.py, let's use oslo_serialization.jsoutils instead. Change-Id: I522d26f3533bd78af978add02f0a4cc13b020924
This commit is contained in:
parent
82bfad9662
commit
f97ee52b09
@ -11,10 +11,10 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import json
|
|
||||||
import kafka
|
import kafka
|
||||||
from kafka.common import KafkaError
|
from kafka.common import KafkaError
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
import testscenarios
|
import testscenarios
|
||||||
from testtools.testcase import unittest
|
from testtools.testcase import unittest
|
||||||
import time
|
import time
|
||||||
@ -145,9 +145,9 @@ class TestKafkaConnection(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
conn.consumer = mock.MagicMock()
|
conn.consumer = mock.MagicMock()
|
||||||
conn.consumer.fetch_messages = mock.MagicMock(
|
conn.consumer.fetch_messages = mock.MagicMock(
|
||||||
return_value=iter([json.dumps(fake_message)]))
|
return_value=iter([jsonutils.dumps(fake_message)]))
|
||||||
|
|
||||||
self.assertEqual(fake_message, json.loads(conn.consume()[0]))
|
self.assertEqual(fake_message, jsonutils.loads(conn.consume()[0]))
|
||||||
self.assertEqual(1, len(conn.consumer.fetch_messages.mock_calls))
|
self.assertEqual(1, len(conn.consumer.fetch_messages.mock_calls))
|
||||||
|
|
||||||
@mock.patch.object(kafka_driver.Connection, '_ensure_connection')
|
@mock.patch.object(kafka_driver.Connection, '_ensure_connection')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user