diff options
| author | Riccardo Pittau <elfosardo@gmail.com> | 2022-06-17 09:34:07 +0200 |
|---|---|---|
| committer | Riccardo Pittau <elfosardo@gmail.com> | 2022-06-17 09:37:35 +0200 |
| commit | 64ffd2ee8052e69d56c4bba7fa8c4e6eae145af1 (patch) | |
| tree | d5f20ee2679c9074c1fb6c7739ff21601d28d00c /ironic_python_agent/tests | |
| parent | 09ea41c83dda9b46739c1d9d0498476db855d952 (diff) | |
| download | ironic-python-agent-64ffd2ee8052e69d56c4bba7fa8c4e6eae145af1.tar.gz | |
Remove oslo.serialization dependency
Use pure json instead of jsonutils.
Borrow encode function from oslo.serialization to be used in the
utils module.
Change-Id: Ied9a2259a4329a86b4f0853bd1fb187563c0a036
Diffstat (limited to 'ironic_python_agent/tests')
| -rw-r--r-- | ironic_python_agent/tests/unit/test_agent.py | 6 | ||||
| -rw-r--r-- | ironic_python_agent/tests/unit/test_ironic_api_client.py | 11 | ||||
| -rw-r--r-- | ironic_python_agent/tests/unit/test_utils.py | 4 |
3 files changed, 10 insertions, 11 deletions
diff --git a/ironic_python_agent/tests/unit/test_agent.py b/ironic_python_agent/tests/unit/test_agent.py index d90b0414..b5e40bf6 100644 --- a/ironic_python_agent/tests/unit/test_agent.py +++ b/ironic_python_agent/tests/unit/test_agent.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import socket import time from unittest import mock @@ -19,7 +20,6 @@ from unittest import mock from ironic_lib import exception as lib_exc from oslo_concurrency import processutils from oslo_config import cfg -from oslo_serialization import jsonutils import pkg_resources from stevedore import extension @@ -192,8 +192,8 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest): # object. a_encoded = self.encoder.encode(a) b_encoded = self.encoder.encode(b) - self.assertEqual(jsonutils.loads(a_encoded), - jsonutils.loads(b_encoded)) + self.assertEqual(json.loads(a_encoded), + json.loads(b_encoded)) def test_get_status(self): started_at = time.time() diff --git a/ironic_python_agent/tests/unit/test_ironic_api_client.py b/ironic_python_agent/tests/unit/test_ironic_api_client.py index ba603651..8c05652c 100644 --- a/ironic_python_agent/tests/unit/test_ironic_api_client.py +++ b/ironic_python_agent/tests/unit/test_ironic_api_client.py @@ -16,7 +16,6 @@ import json from unittest import mock from oslo_config import cfg -from oslo_serialization import jsonutils import requests from ironic_python_agent import errors @@ -149,7 +148,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): expected_data = { 'callback_url': 'http://192.0.2.1:9999', 'agent_version': version.__version__} - self.assertEqual(jsonutils.dumps(expected_data), data) + self.assertEqual(json.dumps(expected_data), data) def test_successful_heartbeat_ip6(self): response = FakeResponse(status_code=202) @@ -172,7 +171,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): expected_data = { 'callback_url': 'http://[fc00:1111::4]:9999', 'agent_version': version.__version__} - self.assertEqual(jsonutils.dumps(expected_data), data) + self.assertEqual(json.dumps(expected_data), data) def test_successful_heartbeat_with_token(self): response = FakeResponse(status_code=202) @@ -197,7 +196,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): 'callback_url': 'http://192.0.2.1:9999', 'agent_token': 'magical', 'agent_version': version.__version__} - self.assertEqual(jsonutils.dumps(expected_data), data) + self.assertEqual(json.dumps(expected_data), data) def test_heartbeat_agent_version_unsupported(self): response = FakeResponse(status_code=202) @@ -218,7 +217,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): self.assertEqual(API_URL + heartbeat_path, request_args[1]) expected_data = { 'callback_url': 'http://[fc00:1111::4]:9999'} - self.assertEqual(jsonutils.dumps(expected_data), data) + self.assertEqual(json.dumps(expected_data), data) def test_successful_heartbeat_with_verify_ca(self): response = FakeResponse(status_code=202) @@ -246,7 +245,7 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest): 'agent_token': 'magical', 'agent_version': version.__version__, 'agent_verify_ca': 'I am a cert'} - self.assertEqual(jsonutils.dumps(expected_data), data) + self.assertEqual(json.dumps(expected_data), data) headers = self.api_client.session.request.call_args[1]['headers'] self.assertEqual( '%d.%d' % ironic_api_client.AGENT_VERIFY_CA_IRONIC_VERSION, diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py index c99f7dca..b975923c 100644 --- a/ironic_python_agent/tests/unit/test_utils.py +++ b/ironic_python_agent/tests/unit/test_utils.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import base64 import errno import glob import io @@ -25,7 +26,6 @@ from unittest import mock from ironic_lib import utils as ironic_utils from oslo_concurrency import processutils -from oslo_serialization import base64 import requests import testtools @@ -320,7 +320,7 @@ class TestUtils(ironic_agent_base.IronicAgentTest): data = utils.gzip_and_b64encode(io_dict=io_dict) self.assertIsInstance(data, str) - res = io.BytesIO(base64.decode_as_bytes(data)) + res = io.BytesIO(base64.b64decode(data)) with tarfile.open(fileobj=res) as tar: members = [(m.name, m.size) for m in tar] self.assertEqual([('fake-name', len(contents))], members) |
