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
This commit is contained in:
Cyril Roelandt 2024-03-14 04:03:08 +01:00
parent 2f9a523765
commit 0970dd4096
2 changed files with 4 additions and 2 deletions

View File

@ -194,6 +194,7 @@ class ClearCachedImage(command.Command):
"--cache", "--cache",
action="store_const", action="store_const",
const="cache", const="cache",
default="both",
dest="target", dest="target",
help=_("Clears all the cached images"), help=_("Clears all the cached images"),
) )
@ -201,6 +202,7 @@ class ClearCachedImage(command.Command):
"--queue", "--queue",
action="store_const", action="store_const",
const="queue", const="queue",
default="both",
dest="target", dest="target",
help=_("Clears all the queued images"), help=_("Clears all the queued images"),
) )

View File

@ -184,13 +184,13 @@ class TestCacheClear(fakes.TestImagev2):
def test_cache_clear_no_option(self): def test_cache_clear_no_option(self):
arglist = [] arglist = []
verifylist = [('target', None)] verifylist = [('target', 'both')]
parsed_args = self.check_parser(self.cmd, arglist, verifylist) parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args) self.cmd.take_action(parsed_args)
self.assertIsNone( 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): def test_cache_clear_queue_option(self):