Merge "Change how we test for call" into stable/train

This commit is contained in:
Zuul 2020-03-17 20:05:29 +00:00 committed by Gerrit Code Review
commit b1602d2e7c
1 changed files with 27 additions and 9 deletions

View File

@ -2068,7 +2068,7 @@ class TestPythonImageUploader(base.TestCase):
],
'mediaType': image_uploader.MEDIA_MANIFEST_V2
})
expected_manifest_str = json.dumps({
expected_manifest = {
'config': {
'digest': 'sha256:1234',
'size': 2,
@ -2079,7 +2079,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
@ -2090,10 +2090,16 @@ class TestPythonImageUploader(base.TestCase):
)
calls = [mock.call(build_url,
data=expected_manifest_str.encode('utf-8'),
data=mock.ANY,
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):
@ -2114,7 +2120,7 @@ class TestPythonImageUploader(base.TestCase):
{'digest': 'sha256:bbbb'},
],
})
expected_manifest_str = json.dumps({
expected_manifest = {
'config': {
'digest': 'sha256:1234',
'size': 2,
@ -2125,7 +2131,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,
@ -2133,11 +2139,17 @@ class TestPythonImageUploader(base.TestCase):
)
calls = [mock.call(target_url,
expected_manifest_str,
mock.ANY,
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.'
'BaseImageUploader.check_status')
@ -2173,7 +2185,7 @@ class TestPythonImageUploader(base.TestCase):
],
'mediaType': image_uploader.MEDIA_OCI_MANIFEST_V1
})
expected_manifest_str = json.dumps({
expected_manifest = {
'config': {
'digest': 'sha256:1234',
'size': 2,
@ -2184,7 +2196,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
@ -2195,10 +2207,16 @@ class TestPythonImageUploader(base.TestCase):
)
calls = [mock.call(build_url,
data=expected_manifest_str.encode('utf-8'),
data=mock.ANY,
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('os.environ')
@mock.patch('subprocess.Popen')