summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorPavlo Shchelokovskyy <shchelokovskyy@gmail.com>2018-05-14 17:57:28 +0000
committerPavlo Shchelokovskyy <shchelokovskyy@gmail.com>2018-07-09 15:07:24 +0300
commitb9fab849f7be93fa62e793ce68303a9473c54fa7 (patch)
tree7906e40861f4d7477fa24306de176686c176f600 /openstackclient/tests
parentc5a0c3ad5dff4cd59c16104e3c419aae6a8e91d9 (diff)
downloadpython-openstackclient-b9fab849f7be93fa62e793ce68303a9473c54fa7.tar.gz
Skip calls to glance and nova when got no servers
save (potentially many) HTTP calls to Glance API for image list and a call to Nova API for flavor list when the server list actually returned no servers. Change-Id: I93a56138c50b82fb4dce67a2f788107f71c5f423 Story: #2002039 Task: #19681
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/unit/compute/v2/test_server.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py
index a53c6c81..46d4c241 100644
--- a/openstackclient/tests/unit/compute/v2/test_server.py
+++ b/openstackclient/tests/unit/compute/v2/test_server.py
@@ -1947,6 +1947,25 @@ class TestServerList(TestServer):
self.assertEqual(self.columns, columns)
self.assertEqual(tuple(self.data), tuple(data))
+ def test_server_list_no_servers(self):
+ arglist = []
+ verifylist = [
+ ('all_projects', False),
+ ('long', False),
+ ('deleted', False),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+ self.servers_mock.list.return_value = []
+ self.data = ()
+
+ columns, data = self.cmd.take_action(parsed_args)
+
+ self.servers_mock.list.assert_called_with(**self.kwargs)
+ self.assertEqual(0, self.images_mock.list.call_count)
+ self.assertEqual(0, self.flavors_mock.list.call_count)
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(tuple(self.data), tuple(data))
+
def test_server_list_long_option(self):
arglist = [
'--long',