diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index 34c6717b5..7a8169cbe 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -18,6 +18,7 @@ import argparse import base64 +import collections import datetime import os @@ -43,6 +44,11 @@ FAKE_UUID_1 = fakes.FAKE_IMAGE_UUID_1 FAKE_UUID_2 = fakes.FAKE_IMAGE_UUID_2 +# Converting dictionary to object +TestAbsoluteLimits = collections.namedtuple("TestAbsoluteLimits", + ["name", "value"]) + + class ShellFixture(fixtures.Fixture): def setUp(self): super(ShellFixture, self).setUp() @@ -2814,6 +2820,20 @@ class ShellTest(utils.TestCase): self.assertIn('Verb', stdout) self.assertIn('Name', stdout) + def test_print_absolute_limits(self): + # Note: This test is to validate that no exception is + # thrown if in case we pass multiple custom fields + limits = [TestAbsoluteLimits('maxTotalPrivateNetworks', 3), + TestAbsoluteLimits('totalPrivateNetworksUsed', 0), + # Above two fields are custom fields + TestAbsoluteLimits('maxImageMeta', 15), + TestAbsoluteLimits('totalCoresUsed', 10), + TestAbsoluteLimits('totalInstancesUsed', 5), + TestAbsoluteLimits('maxServerMeta', 10), + TestAbsoluteLimits('totalRAMUsed', 10240), + TestAbsoluteLimits('totalFloatingIpsUsed', 10)] + novaclient.v2.shell._print_absolute_limits(limits=limits) + def test_limits_2_57(self): """Tests the limits command at microversion 2.57 where personality size limits should not be shown. diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 7c05d1691..2343c6964 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -2853,7 +2853,8 @@ def _print_absolute_limits(limits): used[name] = l.value else: other[name] = l.value - columns.append('Other') + if 'Other' not in columns: + columns.append('Other') if name not in limit_names: limit_names.append(name)