diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-06-11 18:41:30 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-06-11 18:41:30 +0000 |
| commit | df5399a4c45f64771ed127bdc86f5b3c5ef8a492 (patch) | |
| tree | a9d98b00a82f7c8030ca4a28d5d4f15e363372f5 /troveclient | |
| parent | 0b740d0656b9416eccdd3aedf2865c5836698b0f (diff) | |
| parent | 6626ef7bbba5b20ff4f2f2e2b7a65a1fb5642177 (diff) | |
| download | python-troveclient-df5399a4c45f64771ed127bdc86f5b3c5ef8a492.tar.gz | |
Merge "Add limit-list to OSC"
Diffstat (limited to 'troveclient')
| -rw-r--r-- | troveclient/osc/v1/database_limits.py | 34 | ||||
| -rw-r--r-- | troveclient/tests/osc/v1/fakes.py | 15 | ||||
| -rw-r--r-- | troveclient/tests/osc/v1/test_database_limits.py | 42 |
3 files changed, 91 insertions, 0 deletions
diff --git a/troveclient/osc/v1/database_limits.py b/troveclient/osc/v1/database_limits.py new file mode 100644 index 0000000..7df0d2a --- /dev/null +++ b/troveclient/osc/v1/database_limits.py @@ -0,0 +1,34 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Database v1 Limits action implementations""" + +from osc_lib.command import command +from osc_lib import utils as osc_utils + +from troveclient.i18n import _ +from troveclient import utils + + +class ListDatabaseLimits(command.Lister): + + _description = _("List database limits") + columns = ['Value', 'Verb', 'Remaining', 'Unit'] + + def take_action(self, parsed_args): + database_limits = self.app.client_manager.database.limits + limits = database_limits.list() + # Pop the first one, its absolute limits + utils.print_dict(limits.pop(0)._info) + limits = [osc_utils.get_item_properties(i, self.columns) + for i in limits] + return self.columns, limits diff --git a/troveclient/tests/osc/v1/fakes.py b/troveclient/tests/osc/v1/fakes.py index bd80d65..9edbc9e 100644 --- a/troveclient/tests/osc/v1/fakes.py +++ b/troveclient/tests/osc/v1/fakes.py @@ -18,6 +18,7 @@ from troveclient.tests.osc import utils from troveclient.v1 import backups from troveclient.v1 import clusters from troveclient.v1 import flavors +from troveclient.v1 import limits class TestDatabasev1(utils.TestCommand): @@ -53,3 +54,17 @@ class FakeConfigurations(object): def get_configurations_c_123(self): return flavors.Flavor(None, self.fake_config[0]) + + +class FakeLimits(object): + fake_limits = fakes.FakeHTTPClient().get_limits()[2]['limits'] + + def get_absolute_limits(self): + return limits.Limit(None, self.fake_limits[0]) + + def get_non_absolute_limits(self): + return limits.Limit(None, + {'value': 200, + 'verb': 'DELETE', + 'remaining': 200, + 'unit': 'MINUTE'}) diff --git a/troveclient/tests/osc/v1/test_database_limits.py b/troveclient/tests/osc/v1/test_database_limits.py new file mode 100644 index 0000000..497b052 --- /dev/null +++ b/troveclient/tests/osc/v1/test_database_limits.py @@ -0,0 +1,42 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from troveclient import common +from troveclient.osc.v1 import database_limits +from troveclient.tests.osc.v1 import fakes + + +class TestLimits(fakes.TestDatabasev1): + fake_limits = fakes.FakeLimits() + + def setUp(self): + super(TestLimits, self).setUp() + self.limit_client = self.app.client_manager.database.limits + + +class TestLimitList(TestLimits): + columns = database_limits.ListDatabaseLimits.columns + non_absolute_values = (200, 'DELETE', 200, 'MINUTE') + + def setUp(self): + super(TestLimitList, self).setUp() + self.cmd = database_limits.ListDatabaseLimits(self.app, None) + data = [self.fake_limits.get_absolute_limits(), + self.fake_limits.get_non_absolute_limits()] + self.limit_client.list.return_value = common.Paginated(data) + + def test_limit_list_defaults(self): + parsed_args = self.check_parser(self.cmd, [], []) + columns, data = self.cmd.take_action(parsed_args) + self.limit_client.list.assert_called_once_with() + self.assertEqual(self.columns, columns) + self.assertEqual([self.non_absolute_values], data) |
