summaryrefslogtreecommitdiff
path: root/oslo_utils/tests/test_imageutils.py
diff options
context:
space:
mode:
authorTakashi Kajinami <tkajinam@redhat.com>2021-09-04 23:03:17 +0900
committerTakashi Kajinami <tkajinam@redhat.com>2021-09-05 00:43:48 +0900
commit2922a3491a5987aa80f0612df44bd60ed22a0225 (patch)
tree85190ea5494b83146908f79e6fd232b17db3a4da /oslo_utils/tests/test_imageutils.py
parent2c74bb92e5e9561e2ad1386c2e14fb042d6dc062 (diff)
downloadoslo-utils-2922a3491a5987aa80f0612df44bd60ed22a0225.tar.gz
QemuImgInfo: Fix inconsistent value format of encrypted
The qemu-img info command shows the encrpyed field in different formats according to the output format. When the default human format is used the field can be 'yes' or None while when json format is used the same field can be True or False. This change ensures the corresponding attribute has the consistent format regardless of the output format used. Closes-Bug: #1942682 Change-Id: I949f07582a708114fdfba76f1a05aa3a3e5c4f40
Diffstat (limited to 'oslo_utils/tests/test_imageutils.py')
-rw-r--r--oslo_utils/tests/test_imageutils.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/oslo_utils/tests/test_imageutils.py b/oslo_utils/tests/test_imageutils.py
index 63e0ee9..6b25226 100644
--- a/oslo_utils/tests/test_imageutils.py
+++ b/oslo_utils/tests/test_imageutils.py
@@ -238,7 +238,8 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase):
"cluster-size": 65536,
"format": "qcow2",
"actual-size": 13168640,
- "format-specific": {"data": {"foo": "bar"}}
+ "format-specific": {"data": {"foo": "bar"}},
+ "encrypted": true
}'''
image_info = imageutils.QemuImgInfo(img_output, format='json')
mock_deprecate.assert_not_called()
@@ -248,6 +249,7 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase):
self.assertEqual('qcow2', image_info.file_format)
self.assertEqual(13168640, image_info.disk_size)
self.assertEqual("bar", image_info.format_specific["data"]["foo"])
+ self.assertEqual('yes', image_info.encrypted)
@mock.patch("debtcollector.deprecate")
def test_qemu_img_info_blank(self, mock_deprecate):
@@ -260,3 +262,4 @@ class ImageUtilsJSONTestCase(test_base.BaseTestCase):
self.assertIsNone(image_info.file_format)
self.assertIsNone(image_info.disk_size)
self.assertIsNone(image_info.format_specific)
+ self.assertIsNone(image_info.encrypted)