summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <ralonsoh@redhat.com>2020-03-02 16:40:15 +0000
committerRodolfo Alonso Hernandez <ralonsoh@redhat.com>2020-03-12 11:44:10 +0000
commit711b9c9405c55ca8bb5649e2b56202845356e049 (patch)
tree80198e3becbc8512b5bb0ba26d334093ebb3f808 /openstackclient/tests
parent962efd949feb461283a9bb4a668fbd310f80ba40 (diff)
downloadpython-openstackclient-711b9c9405c55ca8bb5649e2b56202845356e049.tar.gz
Add "fields" parameter to ListSecurityGroup query
This new query parameter will allow to send a query sending the "fields" parameter. This "fields" parameter contains the needed API fields, translated into OVO fields in Neutron server, that require to be retrieved from the DB. As commented in the related bug, the OSC "list" command only prints five parameters, none of them the security group rules. In systems with a reasonable amount of security groups, skipping the unnecessary rule load can save a lot of time. Depends-On: https://review.opendev.org/#/c/710820/ Change-Id: I16f48e292997d029d68f66365db949b9f4b5a0c8 Closes-Bug: #1865223
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/unit/network/v2/test_security_group_network.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/openstackclient/tests/unit/network/v2/test_security_group_network.py b/openstackclient/tests/unit/network/v2/test_security_group_network.py
index 14d57514..67908fa8 100644
--- a/openstackclient/tests/unit/network/v2/test_security_group_network.py
+++ b/openstackclient/tests/unit/network/v2/test_security_group_network.py
@@ -285,7 +285,8 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
columns, data = self.cmd.take_action(parsed_args)
- self.network.security_groups.assert_called_once_with()
+ self.network.security_groups.assert_called_once_with(
+ fields=security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE)
self.assertEqual(self.columns, columns)
self.assertListItemEqual(self.data, list(data))
@@ -300,7 +301,8 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
columns, data = self.cmd.take_action(parsed_args)
- self.network.security_groups.assert_called_once_with()
+ self.network.security_groups.assert_called_once_with(
+ fields=security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE)
self.assertEqual(self.columns, columns)
self.assertListItemEqual(self.data, list(data))
@@ -316,7 +318,9 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
- filters = {'tenant_id': project.id, 'project_id': project.id}
+ filters = {
+ 'tenant_id': project.id, 'project_id': project.id,
+ 'fields': security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE}
self.network.security_groups.assert_called_once_with(**filters)
self.assertEqual(self.columns, columns)
@@ -336,7 +340,9 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
- filters = {'tenant_id': project.id, 'project_id': project.id}
+ filters = {
+ 'tenant_id': project.id, 'project_id': project.id,
+ 'fields': security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE}
self.network.security_groups.assert_called_once_with(**filters)
self.assertEqual(self.columns, columns)
@@ -362,7 +368,8 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
**{'tags': 'red,blue',
'any_tags': 'red,green',
'not_tags': 'orange,yellow',
- 'not_any_tags': 'black,white'}
+ 'not_any_tags': 'black,white',
+ 'fields': security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE}
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))