From 84b1b0ae6255bf35e02d4659336f40bf30250b07 Mon Sep 17 00:00:00 2001 From: Yotaro Konishi Date: Thu, 27 Sep 2018 15:41:38 +0900 Subject: Fix wrong keyword arguments Currently 'openstack database flavor list' command fails when using '--datastore-type' and '--datastore-version-id' options. This change fixes the issue by correcting keyword arguments. This change also adds a test case of listing flavors with the optional arguments. Change-Id: I37be4911d4dda1529e2550344a912e0aa3c50558 Closes-Bug: #1794663 --- ...ong-datastore-flavors-args-in-osc-e0322cb5424f8c1b.yaml | 7 +++++++ troveclient/osc/v1/database_flavors.py | 4 ++-- troveclient/tests/osc/v1/test_database_flavors.py | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-wrong-datastore-flavors-args-in-osc-e0322cb5424f8c1b.yaml diff --git a/releasenotes/notes/fix-wrong-datastore-flavors-args-in-osc-e0322cb5424f8c1b.yaml b/releasenotes/notes/fix-wrong-datastore-flavors-args-in-osc-e0322cb5424f8c1b.yaml new file mode 100644 index 0000000..b1781e8 --- /dev/null +++ b/releasenotes/notes/fix-wrong-datastore-flavors-args-in-osc-e0322cb5424f8c1b.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + [`bug 1794663 `_] + Fixed wrong keyword arguments to make ``openstack database flavor list`` + command work properly with ``--datastore-type`` and + ``--datastore-version-id`` options. diff --git a/troveclient/osc/v1/database_flavors.py b/troveclient/osc/v1/database_flavors.py index 33ef46f..5fb513e 100644 --- a/troveclient/osc/v1/database_flavors.py +++ b/troveclient/osc/v1/database_flavors.py @@ -58,8 +58,8 @@ class ListDatabaseFlavors(command.Lister): db_flavors = self.app.client_manager.database.flavors if parsed_args.datastore_type and parsed_args.datastore_version_id: flavors = db_flavors.list_datastore_version_associated_flavors( - datastore_type=parsed_args.datastore_type, - datastore_version_id=parsed_args.datastore_version_id) + datastore=parsed_args.datastore_type, + version_id=parsed_args.datastore_version_id) elif (not parsed_args.datastore_type and not parsed_args.datastore_version_id): flavors = db_flavors.list() diff --git a/troveclient/tests/osc/v1/test_database_flavors.py b/troveclient/tests/osc/v1/test_database_flavors.py index 9a431d4..6b87f06 100644 --- a/troveclient/tests/osc/v1/test_database_flavors.py +++ b/troveclient/tests/osc/v1/test_database_flavors.py @@ -32,6 +32,8 @@ class TestFlavorList(TestFlavors): self.cmd = database_flavors.ListDatabaseFlavors(self.app, None) self.data = [self.fake_flavors.get_flavors_1()] self.flavor_client.list.return_value = self.data + self.flavor_client.list_datastore_version_associated_flavors. \ + return_value = self.data def test_flavor_list_defaults(self): parsed_args = self.check_parser(self.cmd, [], []) @@ -40,6 +42,18 @@ class TestFlavorList(TestFlavors): self.assertEqual(self.columns, columns) self.assertEqual([self.values], values) + def test_flavor_list_with_optional_args(self): + args = ['--datastore-type', 'mysql', + '--datastore-version-id', '5.6'] + parsed_args = self.check_parser(self.cmd, args, []) + list_flavor_dict = {'datastore': 'mysql', + 'version_id': '5.6'} + columns, values = self.cmd.take_action(parsed_args) + self.flavor_client.list_datastore_version_associated_flavors. \ + assert_called_once_with(**list_flavor_dict) + self.assertEqual(self.columns, columns) + self.assertEqual([self.values], values) + class TestFlavorShow(TestFlavors): -- cgit v1.2.1