Revert "Change how we test for call"

This reverts commit 23ec01dc3f.

Reason to revert:
This library no longer supports Python 2.

Conflicts:
	tripleo_common/tests/image/test_image_uploader.py

Change-Id: I3cb54da0630eb454b55581f04d37eebfb35325a2
Related-Bug: #1867648
This commit is contained in:
Takashi Kajinami 2022-06-23 21:23:42 +09:00
parent 01f2f40ca8
commit d84377e570
1 changed files with 9 additions and 27 deletions

View File

@ -2078,7 +2078,7 @@ class TestPythonImageUploader(base.TestCase):
],
'mediaType': image_uploader.MEDIA_MANIFEST_V2
})
expected_manifest = {
expected_manifest_str = json.dumps({
'config': {
'digest': 'sha256:1234',
'size': 2,
@ -2089,7 +2089,7 @@ class TestPythonImageUploader(base.TestCase):
{'digest': 'sha256:bbbb'},
],
'mediaType': image_uploader.MEDIA_MANIFEST_V2
}
}, indent=3)
expected_headers = {
'Content-Type': image_uploader.MEDIA_MANIFEST_V2
@ -2100,16 +2100,10 @@ class TestPythonImageUploader(base.TestCase):
)
calls = [mock.call(build_url,
data=mock.ANY,
data=expected_manifest_str.encode('utf-8'),
headers=expected_headers,
timeout=30)]
target_put.assert_has_calls(calls)
# We're seeing ordering issues with the py27 checking this field
# so switch to checking it this way
call_manifest = json.loads(
target_put.call_args[1]['data'].decode('utf-8')
)
self.assertEqual(expected_manifest, call_manifest)
@mock.patch('tripleo_common.image.image_export.export_manifest_config')
def test_copy_manifest_config_to_registry_export(self, export_mock):
@ -2130,7 +2124,7 @@ class TestPythonImageUploader(base.TestCase):
{'digest': 'sha256:bbbb'},
],
})
expected_manifest = {
expected_manifest_str = json.dumps({
'config': {
'digest': 'sha256:1234',
'size': 2,
@ -2141,7 +2135,7 @@ class TestPythonImageUploader(base.TestCase):
{'digest': 'sha256:bbbb'},
],
'mediaType': image_uploader.MEDIA_MANIFEST_V2
}
}, indent=3)
self.uploader._copy_manifest_config_to_registry(
target_url, manifest_str, config_str,
@ -2149,17 +2143,11 @@ class TestPythonImageUploader(base.TestCase):
)
calls = [mock.call(target_url,
mock.ANY,
expected_manifest_str,
image_uploader.MEDIA_MANIFEST_V2,
config_str,
multi_arch=False)]
export_mock.assert_has_calls(calls)
# We're seeing ordering issues with the py27 checking this field
# so switch to checking it this way
call_manifest = json.loads(
export_mock.call_args[0][1]
)
self.assertEqual(expected_manifest, call_manifest)
@mock.patch('tripleo_common.image.image_uploader.'
'RegistrySessionHelper.put')
@ -2192,7 +2180,7 @@ class TestPythonImageUploader(base.TestCase):
{'digest': 'sha256:bbbb'},
],
})
expected_manifest = {
expected_manifest_str = json.dumps({
'config': {
'digest': 'sha256:1234',
'size': 2,
@ -2203,7 +2191,7 @@ class TestPythonImageUploader(base.TestCase):
{'digest': 'sha256:bbbb'},
],
'mediaType': image_uploader.MEDIA_MANIFEST_V2
}
}, indent=3)
expected_headers = {
'Content-Type': image_uploader.MEDIA_MANIFEST_V2
@ -2215,16 +2203,10 @@ class TestPythonImageUploader(base.TestCase):
calls = [mock.call(target_session,
build_url,
data=mock.ANY,
data=expected_manifest_str.encode('utf-8'),
headers=expected_headers,
timeout=30)]
put_mock.assert_has_calls(calls)
# We're seeing ordering issues with the py27 checking this field
# so switch to checking it this way
call_manifest = json.loads(
put_mock.call_args[1]['data'].decode('utf-8')
)
self.assertEqual(expected_manifest, call_manifest)
@mock.patch('os.environ')
@mock.patch('subprocess.Popen')