From 0970dd4096ab86ce0efec68772100d29e7996517 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Thu, 14 Mar 2024 04:03:08 +0100 Subject: [PATCH] image cache clear: fix value of default target When using the "openstack image cache clear" command, the "clear_cache" method from the OpenStack SDK is used. It expects its only argument to be one of "both", "cache" or "queue". However, when passing neither "--cache" nor "--queue", it is currently passed None as a value. Fix this by specifying "both" as the default value to be passed. Change-Id: I17c6e3d435a84b4ba453845086ff3fe272b54f58 --- openstackclient/image/v2/cache.py | 2 ++ openstackclient/tests/unit/image/v2/test_cache.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openstackclient/image/v2/cache.py b/openstackclient/image/v2/cache.py index ebb4e5b206..bf27b5e63d 100644 --- a/openstackclient/image/v2/cache.py +++ b/openstackclient/image/v2/cache.py @@ -194,6 +194,7 @@ class ClearCachedImage(command.Command): "--cache", action="store_const", const="cache", + default="both", dest="target", help=_("Clears all the cached images"), ) @@ -201,6 +202,7 @@ class ClearCachedImage(command.Command): "--queue", action="store_const", const="queue", + default="both", dest="target", help=_("Clears all the queued images"), ) diff --git a/openstackclient/tests/unit/image/v2/test_cache.py b/openstackclient/tests/unit/image/v2/test_cache.py index abb0b37327..3624d7867b 100644 --- a/openstackclient/tests/unit/image/v2/test_cache.py +++ b/openstackclient/tests/unit/image/v2/test_cache.py @@ -184,13 +184,13 @@ class TestCacheClear(fakes.TestImagev2): def test_cache_clear_no_option(self): arglist = [] - verifylist = [('target', None)] + verifylist = [('target', 'both')] parsed_args = self.check_parser(self.cmd, arglist, verifylist) self.cmd.take_action(parsed_args) self.assertIsNone( - self.image_client.clear_cache.assert_called_with(None) + self.image_client.clear_cache.assert_called_with('both') ) def test_cache_clear_queue_option(self):