summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2022-10-21 16:40:36 +0100
committerStephen Finucane <sfinucan@redhat.com>2022-11-09 16:51:54 +0000
commitbafece762a5d0b03e28f9d81c98ad46777f56a34 (patch)
tree88f0dc354190802b7875e8e4d969e56f080489f6 /openstackclient/tests/unit
parent31881c0b2b6581e16a1d802b01a52d2b2eefb750 (diff)
downloadpython-openstackclient-bafece762a5d0b03e28f9d81c98ad46777f56a34.tar.gz
image: Ignore '--progress' if providing image data from stdin
You can provide data via stdin when creating an image. Using this with '--progress' makes no sense and causes an error currently. Fix this. Change-Id: I3c2d658b72a7c62931b779b0d19bb97f60a0c655 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/unit')
-rw-r--r--openstackclient/tests/unit/image/v2/test_image.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/image/v2/test_image.py b/openstackclient/tests/unit/image/v2/test_image.py
index f2c11364..e17363a5 100644
--- a/openstackclient/tests/unit/image/v2/test_image.py
+++ b/openstackclient/tests/unit/image/v2/test_image.py
@@ -252,6 +252,37 @@ class TestImageCreate(TestImage):
self.expected_data,
data)
+ @mock.patch('openstackclient.image.v2.image.get_data_file')
+ def test_image_create__progress_ignore_with_stdin(
+ self, mock_get_data_file,
+ ):
+ fake_stdin = io.StringIO('fake-image-data')
+ mock_get_data_file.return_value = (fake_stdin, None)
+
+ arglist = [
+ '--progress',
+ self.new_image.name,
+ ]
+ verifylist = [
+ ('progress', True),
+ ('name', self.new_image.name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ columns, data = self.cmd.take_action(parsed_args)
+
+ self.client.create_image.assert_called_with(
+ name=self.new_image.name,
+ allow_duplicates=True,
+ container_format=image.DEFAULT_CONTAINER_FORMAT,
+ disk_format=image.DEFAULT_DISK_FORMAT,
+ data=fake_stdin,
+ validate_checksum=False,
+ )
+
+ self.assertEqual(self.expected_columns, columns)
+ self.assertCountEqual(self.expected_data, data)
+
def test_image_create_dead_options(self):
arglist = [