python-openstackclient 7.1.3__py3-none-any.whl → 7.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. openstackclient/api/api.py +2 -1
  2. openstackclient/api/image_v2.py +1 -1
  3. openstackclient/api/object_store_v1.py +12 -20
  4. openstackclient/common/clientmanager.py +7 -2
  5. openstackclient/common/module.py +2 -2
  6. openstackclient/common/quota.py +4 -4
  7. openstackclient/compute/v2/flavor.py +1 -1
  8. openstackclient/compute/v2/server.py +122 -59
  9. openstackclient/compute/v2/server_backup.py +1 -1
  10. openstackclient/compute/v2/server_image.py +1 -1
  11. openstackclient/compute/v2/server_migration.py +11 -2
  12. openstackclient/compute/v2/usage.py +3 -3
  13. openstackclient/identity/common.py +1 -1
  14. openstackclient/identity/v2_0/project.py +1 -1
  15. openstackclient/identity/v2_0/role_assignment.py +1 -1
  16. openstackclient/identity/v2_0/user.py +2 -2
  17. openstackclient/identity/v3/access_rule.py +26 -14
  18. openstackclient/identity/v3/identity_provider.py +1 -1
  19. openstackclient/identity/v3/project.py +1 -1
  20. openstackclient/image/v2/image.py +13 -13
  21. openstackclient/image/v2/metadef_objects.py +6 -4
  22. openstackclient/network/common.py +8 -7
  23. openstackclient/network/v2/floating_ip.py +6 -2
  24. openstackclient/network/v2/floating_ip_port_forwarding.py +2 -2
  25. openstackclient/network/v2/l3_conntrack_helper.py +1 -1
  26. openstackclient/network/v2/ndp_proxy.py +1 -0
  27. openstackclient/network/v2/network_agent.py +2 -6
  28. openstackclient/network/v2/network_qos_rule.py +2 -5
  29. openstackclient/network/v2/network_trunk.py +5 -4
  30. openstackclient/network/v2/port.py +18 -3
  31. openstackclient/network/v2/router.py +7 -4
  32. openstackclient/network/v2/subnet_pool.py +2 -2
  33. openstackclient/shell.py +3 -2
  34. openstackclient/tests/functional/common/test_help.py +3 -9
  35. openstackclient/tests/functional/common/test_module.py +1 -1
  36. openstackclient/tests/functional/common/test_quota.py +2 -4
  37. openstackclient/tests/functional/compute/v2/common.py +1 -3
  38. openstackclient/tests/functional/compute/v2/test_hypervisor.py +3 -3
  39. openstackclient/tests/functional/compute/v2/test_keypair.py +2 -2
  40. openstackclient/tests/functional/compute/v2/test_server.py +1 -1
  41. openstackclient/tests/functional/identity/v2/common.py +31 -48
  42. openstackclient/tests/functional/identity/v2/test_catalog.py +1 -1
  43. openstackclient/tests/functional/identity/v2/test_ec2_credentials.py +2 -2
  44. openstackclient/tests/functional/identity/v2/test_endpoint.py +2 -2
  45. openstackclient/tests/functional/identity/v2/test_project.py +8 -8
  46. openstackclient/tests/functional/identity/v2/test_role.py +14 -34
  47. openstackclient/tests/functional/identity/v2/test_service.py +2 -2
  48. openstackclient/tests/functional/identity/v2/test_token.py +1 -1
  49. openstackclient/tests/functional/identity/v2/test_user.py +7 -9
  50. openstackclient/tests/functional/identity/v3/common.py +69 -110
  51. openstackclient/tests/functional/identity/v3/test_access_rule.py +86 -0
  52. openstackclient/tests/functional/identity/v3/test_application_credential.py +18 -44
  53. openstackclient/tests/functional/identity/v3/test_catalog.py +1 -1
  54. openstackclient/tests/functional/identity/v3/test_domain.py +9 -11
  55. openstackclient/tests/functional/identity/v3/test_endpoint.py +15 -27
  56. openstackclient/tests/functional/identity/v3/test_group.py +32 -93
  57. openstackclient/tests/functional/identity/v3/test_idp.py +3 -3
  58. openstackclient/tests/functional/identity/v3/test_limit.py +32 -32
  59. openstackclient/tests/functional/identity/v3/test_project.py +17 -26
  60. openstackclient/tests/functional/identity/v3/test_region.py +6 -7
  61. openstackclient/tests/functional/identity/v3/test_registered_limit.py +27 -36
  62. openstackclient/tests/functional/identity/v3/test_role.py +30 -60
  63. openstackclient/tests/functional/identity/v3/test_role_assignment.py +33 -80
  64. openstackclient/tests/functional/identity/v3/test_service.py +7 -13
  65. openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -3
  66. openstackclient/tests/functional/identity/v3/test_user.py +17 -34
  67. openstackclient/tests/functional/image/v2/test_image.py +1 -3
  68. openstackclient/tests/functional/network/v2/common.py +1 -3
  69. openstackclient/tests/functional/network/v2/test_default_security_group_rule.py +3 -8
  70. openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +27 -31
  71. openstackclient/tests/functional/network/v2/test_network.py +9 -12
  72. openstackclient/tests/functional/network/v2/test_network_agent.py +15 -20
  73. openstackclient/tests/functional/network/v2/test_network_flavor.py +2 -2
  74. openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +17 -39
  75. openstackclient/tests/functional/network/v2/test_network_qos_rule.py +48 -63
  76. openstackclient/tests/functional/network/v2/test_network_qos_rule_type.py +1 -1
  77. openstackclient/tests/functional/network/v2/test_network_segment_range.py +2 -2
  78. openstackclient/tests/functional/network/v2/test_network_trunk.py +15 -25
  79. openstackclient/tests/functional/network/v2/test_port.py +28 -34
  80. openstackclient/tests/functional/network/v2/test_router.py +13 -19
  81. openstackclient/tests/functional/object/v1/test_object.py +4 -7
  82. openstackclient/tests/functional/volume/base.py +5 -17
  83. openstackclient/tests/functional/volume/v1/test_volume_type.py +11 -11
  84. openstackclient/tests/functional/volume/v2/test_volume_backup.py +1 -1
  85. openstackclient/tests/functional/volume/v2/test_volume_type.py +13 -15
  86. openstackclient/tests/functional/volume/v3/test_volume_type.py +13 -15
  87. openstackclient/tests/unit/api/test_compute_v2.py +0 -5
  88. openstackclient/tests/unit/api/test_object_store_v1.py +6 -4
  89. openstackclient/tests/unit/common/test_extension.py +24 -31
  90. openstackclient/tests/unit/compute/v2/test_host.py +0 -1
  91. openstackclient/tests/unit/compute/v2/test_server.py +123 -115
  92. openstackclient/tests/unit/identity/v3/test_access_rule.py +65 -64
  93. openstackclient/tests/unit/identity/v3/test_group.py +4 -10
  94. openstackclient/tests/unit/identity/v3/test_limit.py +2 -2
  95. openstackclient/tests/unit/image/v2/test_metadef_objects.py +1 -2
  96. openstackclient/tests/unit/image/v2/test_metadef_resource_type_association.py +2 -6
  97. openstackclient/tests/unit/integ/base.py +1 -1
  98. openstackclient/tests/unit/network/v2/test_default_security_group_rule.py +3 -3
  99. openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py +4 -4
  100. openstackclient/tests/unit/network/v2/test_local_ip_association.py +2 -2
  101. openstackclient/tests/unit/network/v2/test_network_qos_rule.py +12 -13
  102. openstackclient/tests/unit/network/v2/test_network_trunk.py +31 -35
  103. openstackclient/tests/unit/network/v2/test_port.py +40 -17
  104. openstackclient/tests/unit/network/v2/test_subnet_pool.py +1 -1
  105. openstackclient/tests/unit/object/v1/test_object.py +1 -1
  106. openstackclient/tests/unit/utils.py +2 -2
  107. openstackclient/volume/client.py +1 -1
  108. openstackclient/volume/v1/volume.py +2 -2
  109. openstackclient/volume/v1/volume_backup.py +2 -2
  110. openstackclient/volume/v1/volume_snapshot.py +2 -2
  111. openstackclient/volume/v2/volume.py +2 -2
  112. openstackclient/volume/v2/volume_backup.py +2 -2
  113. openstackclient/volume/v2/volume_snapshot.py +2 -2
  114. openstackclient/volume/v2/volume_type.py +4 -4
  115. openstackclient/volume/v3/service.py +0 -1
  116. openstackclient/volume/v3/volume.py +3 -3
  117. openstackclient/volume/v3/volume_backup.py +2 -2
  118. openstackclient/volume/v3/volume_group.py +3 -7
  119. openstackclient/volume/v3/volume_type.py +6 -6
  120. {python_openstackclient-7.1.3.dist-info → python_openstackclient-7.2.1.dist-info}/AUTHORS +3 -0
  121. {python_openstackclient-7.1.3.dist-info → python_openstackclient-7.2.1.dist-info}/METADATA +2 -3
  122. {python_openstackclient-7.1.3.dist-info → python_openstackclient-7.2.1.dist-info}/RECORD +127 -126
  123. python_openstackclient-7.2.1.dist-info/pbr.json +1 -0
  124. python_openstackclient-7.1.3.dist-info/pbr.json +0 -1
  125. {python_openstackclient-7.1.3.dist-info → python_openstackclient-7.2.1.dist-info}/LICENSE +0 -0
  126. {python_openstackclient-7.1.3.dist-info → python_openstackclient-7.2.1.dist-info}/WHEEL +0 -0
  127. {python_openstackclient-7.1.3.dist-info → python_openstackclient-7.2.1.dist-info}/entry_points.txt +0 -0
  128. {python_openstackclient-7.1.3.dist-info → python_openstackclient-7.2.1.dist-info}/top_level.txt +0 -0
@@ -13,72 +13,66 @@
13
13
  # under the License.
14
14
  #
15
15
 
16
- import copy
16
+ from unittest.mock import call
17
17
 
18
- from keystoneclient import exceptions as identity_exc
18
+ from openstack import exceptions as sdk_exceptions
19
+ from openstack.identity.v3 import access_rule as _access_rule
20
+ from openstack.test import fakes as sdk_fakes
19
21
  from osc_lib import exceptions
20
22
 
21
23
  from openstackclient.identity.v3 import access_rule
22
- from openstackclient.tests.unit import fakes
23
24
  from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
24
25
 
25
26
 
26
- class TestAccessRule(identity_fakes.TestIdentityv3):
27
- def setUp(self):
28
- super().setUp()
29
-
30
- identity_manager = self.identity_client
31
- self.access_rules_mock = identity_manager.access_rules
32
- self.access_rules_mock.reset_mock()
33
- self.roles_mock = identity_manager.roles
34
- self.roles_mock.reset_mock()
27
+ class TestAccessRuleDelete(identity_fakes.TestIdentityv3):
28
+ access_rule = sdk_fakes.generate_fake_resource(_access_rule.AccessRule)
35
29
 
36
-
37
- class TestAccessRuleDelete(TestAccessRule):
38
30
  def setUp(self):
39
31
  super().setUp()
40
32
 
41
- # This is the return value for utils.find_resource()
42
- self.access_rules_mock.get.return_value = fakes.FakeResource(
43
- None,
44
- copy.deepcopy(identity_fakes.ACCESS_RULE),
45
- loaded=True,
33
+ self.identity_sdk_client.get_access_rule.return_value = (
34
+ self.access_rule
46
35
  )
47
- self.access_rules_mock.delete.return_value = None
36
+ self.identity_sdk_client.delete_access_rule.return_value = None
48
37
 
49
38
  # Get the command object to test
50
39
  self.cmd = access_rule.DeleteAccessRule(self.app, None)
51
40
 
52
41
  def test_access_rule_delete(self):
53
- arglist = [
54
- identity_fakes.access_rule_id,
55
- ]
56
- verifylist = [('access_rule', [identity_fakes.access_rule_id])]
42
+ arglist = [self.access_rule.id]
43
+ verifylist = [('access_rule', [self.access_rule.id])]
57
44
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
58
45
 
46
+ conn = self.app.client_manager.sdk_connection
47
+ user_id = conn.config.get_auth().get_user_id(conn.identity)
48
+
59
49
  result = self.cmd.take_action(parsed_args)
60
50
 
61
- self.access_rules_mock.delete.assert_called_with(
62
- identity_fakes.access_rule_id,
51
+ self.identity_sdk_client.delete_access_rule.assert_called_with(
52
+ user_id,
53
+ self.access_rule.id,
63
54
  )
64
55
  self.assertIsNone(result)
65
56
 
66
57
  def test_delete_multi_access_rules_with_exception(self):
67
- # mock returns for common.get_resource_by_id
68
- mock_get = self.access_rules_mock.get
69
- mock_get.side_effect = [
70
- mock_get.return_value,
71
- identity_exc.NotFound,
58
+ self.identity_sdk_client.get_access_rule.side_effect = [
59
+ self.access_rule,
60
+ sdk_exceptions.NotFoundException,
72
61
  ]
62
+
73
63
  arglist = [
74
- identity_fakes.access_rule_id,
64
+ self.access_rule.id,
75
65
  'nonexistent_access_rule',
76
66
  ]
77
67
  verifylist = [
78
68
  ('access_rule', arglist),
79
69
  ]
70
+
80
71
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
81
72
 
73
+ conn = self.app.client_manager.sdk_connection
74
+ user_id = conn.config.get_auth().get_user_id(conn.identity)
75
+
82
76
  try:
83
77
  self.cmd.take_action(parsed_args)
84
78
  self.fail('CommandError should be raised.')
@@ -87,26 +81,27 @@ class TestAccessRuleDelete(TestAccessRule):
87
81
  '1 of 2 access rules failed to' ' delete.', str(e)
88
82
  )
89
83
 
90
- mock_get.assert_any_call(identity_fakes.access_rule_id)
91
- mock_get.assert_any_call('nonexistent_access_rule')
84
+ calls = []
85
+ for a in arglist:
86
+ calls.append(call(user_id, a))
87
+
88
+ self.identity_sdk_client.get_access_rule.assert_has_calls(calls)
92
89
 
93
- self.assertEqual(2, mock_get.call_count)
94
- self.access_rules_mock.delete.assert_called_once_with(
95
- identity_fakes.access_rule_id
90
+ self.assertEqual(
91
+ 2, self.identity_sdk_client.get_access_rule.call_count
92
+ )
93
+ self.identity_sdk_client.delete_access_rule.assert_called_once_with(
94
+ user_id, self.access_rule.id
96
95
  )
97
96
 
98
97
 
99
- class TestAccessRuleList(TestAccessRule):
98
+ class TestAccessRuleList(identity_fakes.TestIdentityv3):
99
+ access_rule = sdk_fakes.generate_fake_resource(_access_rule.AccessRule)
100
+
100
101
  def setUp(self):
101
102
  super().setUp()
102
103
 
103
- self.access_rules_mock.list.return_value = [
104
- fakes.FakeResource(
105
- None,
106
- copy.deepcopy(identity_fakes.ACCESS_RULE),
107
- loaded=True,
108
- ),
109
- ]
104
+ self.identity_sdk_client.access_rules.return_value = [self.access_rule]
110
105
 
111
106
  # Get the command object to test
112
107
  self.cmd = access_rule.ListAccessRule(self.app, None)
@@ -116,31 +111,34 @@ class TestAccessRuleList(TestAccessRule):
116
111
  verifylist = []
117
112
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
118
113
 
114
+ conn = self.app.client_manager.sdk_connection
115
+ user_id = conn.config.get_auth().get_user_id(conn.identity)
116
+
119
117
  columns, data = self.cmd.take_action(parsed_args)
120
118
 
121
- self.access_rules_mock.list.assert_called_with(user=None)
119
+ self.identity_sdk_client.access_rules.assert_called_with(user=user_id)
122
120
 
123
121
  collist = ('ID', 'Service', 'Method', 'Path')
124
122
  self.assertEqual(collist, columns)
125
123
  datalist = (
126
124
  (
127
- identity_fakes.access_rule_id,
128
- identity_fakes.access_rule_service,
129
- identity_fakes.access_rule_method,
130
- identity_fakes.access_rule_path,
125
+ self.access_rule.id,
126
+ self.access_rule.service,
127
+ self.access_rule.method,
128
+ self.access_rule.path,
131
129
  ),
132
130
  )
133
131
  self.assertEqual(datalist, tuple(data))
134
132
 
135
133
 
136
- class TestAccessRuleShow(TestAccessRule):
134
+ class TestAccessRuleShow(identity_fakes.TestIdentityv3):
135
+ access_rule = sdk_fakes.generate_fake_resource(_access_rule.AccessRule)
136
+
137
137
  def setUp(self):
138
138
  super().setUp()
139
139
 
140
- self.access_rules_mock.get.return_value = fakes.FakeResource(
141
- None,
142
- copy.deepcopy(identity_fakes.ACCESS_RULE),
143
- loaded=True,
140
+ self.identity_sdk_client.get_access_rule.return_value = (
141
+ self.access_rule
144
142
  )
145
143
 
146
144
  # Get the command object to test
@@ -148,25 +146,28 @@ class TestAccessRuleShow(TestAccessRule):
148
146
 
149
147
  def test_access_rule_show(self):
150
148
  arglist = [
151
- identity_fakes.access_rule_id,
149
+ self.access_rule.id,
152
150
  ]
153
151
  verifylist = [
154
- ('access_rule', identity_fakes.access_rule_id),
152
+ ('access_rule', self.access_rule.id),
155
153
  ]
156
154
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
157
155
 
156
+ conn = self.app.client_manager.sdk_connection
157
+ user_id = conn.config.get_auth().get_user_id(conn.identity)
158
+
158
159
  columns, data = self.cmd.take_action(parsed_args)
159
160
 
160
- self.access_rules_mock.get.assert_called_with(
161
- identity_fakes.access_rule_id
161
+ self.identity_sdk_client.get_access_rule.assert_called_with(
162
+ user_id, self.access_rule.id
162
163
  )
163
164
 
164
- collist = ('id', 'method', 'path', 'service')
165
+ collist = ('ID', 'Method', 'Path', 'Service')
165
166
  self.assertEqual(collist, columns)
166
167
  datalist = (
167
- identity_fakes.access_rule_id,
168
- identity_fakes.access_rule_method,
169
- identity_fakes.access_rule_path,
170
- identity_fakes.access_rule_service,
168
+ self.access_rule.id,
169
+ self.access_rule.method,
170
+ self.access_rule.path,
171
+ self.access_rule.service,
171
172
  )
172
173
  self.assertEqual(datalist, data)
@@ -109,12 +109,9 @@ class TestGroupAddUser(TestGroup):
109
109
  self.cmd.take_action(parsed_args)
110
110
  self.fail('CommandError should be raised.')
111
111
  except exceptions.CommandError as e:
112
- msg = "1 of 2 users not added to group %s." % self._group.name
112
+ msg = f"1 of 2 users not added to group {self._group.name}."
113
113
  self.assertEqual(msg, str(e))
114
- msg = ("%(user)s not added to group %(group)s: ") % {
115
- 'user': self.users[0].name,
116
- 'group': self._group.name,
117
- }
114
+ msg = f"{self.users[0].name} not added to group {self._group.name}: "
118
115
  mock_error.assert_called_once_with(msg)
119
116
 
120
117
 
@@ -561,12 +558,9 @@ class TestGroupRemoveUser(TestGroup):
561
558
  self.cmd.take_action(parsed_args)
562
559
  self.fail('CommandError should be raised.')
563
560
  except exceptions.CommandError as e:
564
- msg = "1 of 2 users not removed from group %s." % self._group.id
561
+ msg = f"1 of 2 users not removed from group {self._group.id}."
565
562
  self.assertEqual(msg, str(e))
566
- msg = ("%(user)s not removed from group %(group)s: ") % {
567
- 'user': self.users[0].id,
568
- 'group': self._group.id,
569
- }
563
+ msg = f"{self.users[0].id} not removed from group {self._group.id}: "
570
564
  mock_error.assert_called_once_with(msg)
571
565
 
572
566
 
@@ -90,7 +90,7 @@ class TestLimitCreate(TestLimit):
90
90
  self.service,
91
91
  identity_fakes.limit_resource_name,
92
92
  resource_limit,
93
- **kwargs
93
+ **kwargs,
94
94
  )
95
95
 
96
96
  collist = (
@@ -154,7 +154,7 @@ class TestLimitCreate(TestLimit):
154
154
  self.service,
155
155
  identity_fakes.limit_resource_name,
156
156
  resource_limit,
157
- **kwargs
157
+ **kwargs,
158
158
  )
159
159
 
160
160
  collist = (
@@ -256,7 +256,6 @@ class TestMetadefObjectPropertyShow(fakes.TestImagev2):
256
256
  parsed_args,
257
257
  )
258
258
  self.assertIn(
259
- 'Property %s not found in object %s.'
260
- % (parsed_args.property, parsed_args.object),
259
+ f'Property {parsed_args.property} not found in object {parsed_args.object}.',
261
260
  str(exc),
262
261
  )
@@ -42,9 +42,7 @@ class TestMetadefResourceTypeAssociationCreate(
42
42
  def setUp(self):
43
43
  super().setUp()
44
44
 
45
- self.image_client.create_metadef_resource_type_association.return_value = (
46
- self.resource_type_association
47
- )
45
+ self.image_client.create_metadef_resource_type_association.return_value = self.resource_type_association
48
46
  self.cmd = metadef_resource_type_association.CreateMetadefResourceTypeAssociation(
49
47
  self.app, None
50
48
  )
@@ -74,9 +72,7 @@ class TestMetadefResourceTypeAssociationDelete(
74
72
  def setUp(self):
75
73
  super().setUp()
76
74
 
77
- self.image_client.delete_metadef_resource_type_association.return_value = (
78
- self.resource_type_association
79
- )
75
+ self.image_client.delete_metadef_resource_type_association.return_value = self.resource_type_association
80
76
  self.cmd = metadef_resource_type_association.DeleteMetadefResourceTypeAssociation(
81
77
  self.app, None
82
78
  )
@@ -18,7 +18,7 @@ from openstackclient.tests.unit import utils
18
18
 
19
19
 
20
20
  HOST = "192.168.5.41"
21
- URL_BASE = "http://%s/identity" % HOST
21
+ URL_BASE = f"http://{HOST}/identity"
22
22
 
23
23
  V2_AUTH_URL = URL_BASE + "/v2.0/"
24
24
  V2_VERSION_RESP = {
@@ -79,7 +79,7 @@ class TestCreateDefaultSecurityGroupRule(TestDefaultSecurityGroupRule):
79
79
  default_security_group_rule_attrs.update(attrs)
80
80
  self._default_sg_rule = sdk_fakes.generate_fake_resource(
81
81
  _default_security_group_rule.DefaultSecurityGroupRule,
82
- **default_security_group_rule_attrs
82
+ **default_security_group_rule_attrs,
83
83
  )
84
84
 
85
85
  self.sdk_client.create_default_security_group_rule.return_value = (
@@ -956,11 +956,11 @@ class TestListDefaultSecurityGroupRule(TestDefaultSecurityGroupRule):
956
956
  # The security group rule to be listed.
957
957
  _default_sg_rule_tcp = sdk_fakes.generate_fake_resource(
958
958
  _default_security_group_rule.DefaultSecurityGroupRule,
959
- **{'protocol': 'tcp', 'port_range_max': 80, 'port_range_min': 80}
959
+ **{'protocol': 'tcp', 'port_range_max': 80, 'port_range_min': 80},
960
960
  )
961
961
  _default_sg_rule_icmp = sdk_fakes.generate_fake_resource(
962
962
  _default_security_group_rule.DefaultSecurityGroupRule,
963
- **{'protocol': 'icmp', 'remote_ip_prefix': '10.0.2.0/24'}
963
+ **{'protocol': 'icmp', 'remote_ip_prefix': '10.0.2.0/24'},
964
964
  )
965
965
  _default_sg_rules = [
966
966
  _default_sg_rule_tcp,
@@ -153,7 +153,7 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
153
153
  'internal_port_id': self.new_port_forwarding_with_ranges.internal_port_id, # noqa: E501
154
154
  'protocol': self.new_port_forwarding_with_ranges.protocol,
155
155
  'description': self.new_port_forwarding_with_ranges.description, # noqa: E501
156
- }
156
+ },
157
157
  )
158
158
  self.assertEqual(self.columns, columns)
159
159
  self.assertEqual(self.data, data)
@@ -334,7 +334,7 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
334
334
  'internal_port_id': self.new_port_forwarding.internal_port_id,
335
335
  'protocol': self.new_port_forwarding.protocol,
336
336
  'description': self.new_port_forwarding.description,
337
- }
337
+ },
338
338
  )
339
339
  self.assertEqual(self.columns, columns)
340
340
  self.assertEqual(self.data, data)
@@ -587,7 +587,7 @@ class TestSetFloatingIPPortForwarding(TestFloatingIPPortForwarding):
587
587
  self.network_client.update_floating_ip_port_forwarding.assert_called_with(
588
588
  self._port_forwarding.floatingip_id,
589
589
  self._port_forwarding.id,
590
- **attrs
590
+ **attrs,
591
591
  )
592
592
  self.assertIsNone(result)
593
593
 
@@ -648,7 +648,7 @@ class TestSetFloatingIPPortForwarding(TestFloatingIPPortForwarding):
648
648
  self.network_client.update_floating_ip_port_forwarding.assert_called_with(
649
649
  self._port_forwarding.floatingip_id,
650
650
  self._port_forwarding.id,
651
- **attrs
651
+ **attrs,
652
652
  )
653
653
  self.assertIsNone(result)
654
654
 
@@ -86,7 +86,7 @@ class TestCreateLocalIPAssociation(TestLocalIPAssociation):
86
86
  self.new_local_ip_association.local_ip_id,
87
87
  **{
88
88
  'fixed_port_id': self.new_local_ip_association.fixed_port_id,
89
- }
89
+ },
90
90
  )
91
91
  self.assertEqual(set(self.columns), set(columns))
92
92
  self.assertEqual(set(self.data), set(data))
@@ -111,7 +111,7 @@ class TestCreateLocalIPAssociation(TestLocalIPAssociation):
111
111
  **{
112
112
  'fixed_port_id': self.new_local_ip_association.fixed_port_id,
113
113
  'fixed_ip': self.new_local_ip_association.fixed_ip,
114
- }
114
+ },
115
115
  )
116
116
  self.assertEqual(set(self.columns), set(columns))
117
117
  self.assertEqual(set(self.data), set(data))
@@ -137,7 +137,7 @@ class TestCreateNetworkQosRuleMinimumBandwidth(TestNetworkQosRule):
137
137
  **{
138
138
  'min_kbps': self.new_rule.min_kbps,
139
139
  'direction': self.new_rule.direction,
140
- }
140
+ },
141
141
  )
142
142
  self.assertEqual(self.columns, columns)
143
143
  self.assertEqual(self.data, data)
@@ -244,7 +244,7 @@ class TestCreateNetworkQosRuleMinimumPacketRate(TestNetworkQosRule):
244
244
  **{
245
245
  'min_kpps': self.new_rule.min_kpps,
246
246
  'direction': self.new_rule.direction,
247
- }
247
+ },
248
248
  )
249
249
  self.assertEqual(self.columns, columns)
250
250
  self.assertEqual(self.data, data)
@@ -473,7 +473,7 @@ class TestCreateNetworkQosRuleBandwidtLimit(TestNetworkQosRule):
473
473
  **{
474
474
  'max_kbps': self.new_rule.max_kbps,
475
475
  'direction': self.new_rule.direction,
476
- }
476
+ },
477
477
  )
478
478
  self.assertEqual(self.columns, columns)
479
479
  self.assertEqual(expected_data, data)
@@ -507,7 +507,7 @@ class TestCreateNetworkQosRuleBandwidtLimit(TestNetworkQosRule):
507
507
  'max_kbps': self.new_rule.max_kbps,
508
508
  'max_burst_kbps': self.new_rule.max_burst_kbits,
509
509
  'direction': self.new_rule.direction,
510
- }
510
+ },
511
511
  )
512
512
  self.assertEqual(self.columns, columns)
513
513
  self.assertEqual(self.data, data)
@@ -903,9 +903,9 @@ class TestSetNetworkQosRuleMinimumBandwidth(TestNetworkQosRule):
903
903
  self.cmd.take_action(parsed_args)
904
904
  except exceptions.CommandError as e:
905
905
  msg = (
906
- 'Failed to set Network QoS rule ID "%(rule)s": Rule type '
906
+ f'Failed to set Network QoS rule ID "{self.new_rule.id}": Rule type '
907
907
  '"minimum-bandwidth" only requires arguments: direction, '
908
- 'min_kbps' % {'rule': self.new_rule.id}
908
+ 'min_kbps'
909
909
  )
910
910
  self.assertEqual(msg, str(e))
911
911
 
@@ -1007,9 +1007,9 @@ class TestSetNetworkQosRuleMinimumPacketRate(TestNetworkQosRule):
1007
1007
  self.cmd.take_action(parsed_args)
1008
1008
  except exceptions.CommandError as e:
1009
1009
  msg = (
1010
- 'Failed to set Network QoS rule ID "%(rule)s": Rule type '
1010
+ f'Failed to set Network QoS rule ID "{self.new_rule.id}": Rule type '
1011
1011
  '"minimum-packet-rate" only requires arguments: direction, '
1012
- 'min_kpps' % {'rule': self.new_rule.id}
1012
+ 'min_kpps'
1013
1013
  )
1014
1014
  self.assertEqual(msg, str(e))
1015
1015
 
@@ -1111,9 +1111,8 @@ class TestSetNetworkQosRuleDSCPMarking(TestNetworkQosRule):
1111
1111
  self.cmd.take_action(parsed_args)
1112
1112
  except exceptions.CommandError as e:
1113
1113
  msg = (
1114
- 'Failed to set Network QoS rule ID "%(rule)s": Rule type '
1114
+ f'Failed to set Network QoS rule ID "{self.new_rule.id}": Rule type '
1115
1115
  '"dscp-marking" only requires arguments: dscp_mark'
1116
- % {'rule': self.new_rule.id}
1117
1116
  )
1118
1117
  self.assertEqual(msg, str(e))
1119
1118
 
@@ -1249,7 +1248,7 @@ class TestSetNetworkQosRuleBandwidthLimit(TestNetworkQosRule):
1249
1248
  self.addCleanup(self._reset_direction, self.new_rule.direction)
1250
1249
 
1251
1250
  arglist = [
1252
- '--%s' % direction,
1251
+ f'--{direction}',
1253
1252
  self.new_rule.qos_policy_id,
1254
1253
  self.new_rule.id,
1255
1254
  ]
@@ -1288,9 +1287,9 @@ class TestSetNetworkQosRuleBandwidthLimit(TestNetworkQosRule):
1288
1287
  self.cmd.take_action(parsed_args)
1289
1288
  except exceptions.CommandError as e:
1290
1289
  msg = (
1291
- 'Failed to set Network QoS rule ID "%(rule)s": Rule type '
1290
+ f'Failed to set Network QoS rule ID "{self.new_rule.id}": Rule type '
1292
1291
  '"bandwidth-limit" only requires arguments: direction, '
1293
- 'max_burst_kbps, max_kbps' % {'rule': self.new_rule.id}
1292
+ 'max_burst_kbps, max_kbps'
1294
1293
  )
1295
1294
  self.assertEqual(msg, str(e))
1296
1295
 
@@ -143,13 +143,12 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
143
143
  "--parent-port",
144
144
  self.new_trunk.port_id,
145
145
  "--subport",
146
- 'port=%(port)s,segmentation-type=%(seg_type)s,'
147
- 'segmentation-id=%(seg_id)s'
148
- % {
149
- 'seg_id': subport['segmentation_id'],
150
- 'seg_type': subport['segmentation_type'],
151
- 'port': subport['port_id'],
152
- },
146
+ 'port={port},segmentation-type={seg_type},'
147
+ 'segmentation-id={seg_id}'.format(
148
+ seg_id=subport['segmentation_id'],
149
+ seg_type=subport['segmentation_type'],
150
+ port=subport['port_id'],
151
+ ),
153
152
  self.new_trunk.name,
154
153
  ]
155
154
  verifylist = [
@@ -194,12 +193,11 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
194
193
  "--parent-port",
195
194
  self.new_trunk.port_id,
196
195
  "--subport",
197
- "port=%(port)s,segmentation-type=%(seg_type)s,"
198
- "segmentation-id=boom"
199
- % {
200
- 'seg_type': subport['segmentation_type'],
201
- 'port': subport['port_id'],
202
- },
196
+ "port={port},segmentation-type={seg_type},"
197
+ "segmentation-id=boom".format(
198
+ seg_type=subport['segmentation_type'],
199
+ port=subport['port_id'],
200
+ ),
203
201
  self.new_trunk.name,
204
202
  ]
205
203
  verifylist = [
@@ -265,12 +263,10 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
265
263
  '--parent-port',
266
264
  self.new_trunk.port_id,
267
265
  '--subport',
268
- 'segmentation-type=%(seg_type)s,'
269
- 'segmentation-id=%(seg_id)s'
270
- % {
271
- 'seg_id': subport['segmentation_id'],
272
- 'seg_type': subport['segmentation_type'],
273
- },
266
+ 'segmentation-type={seg_type},' 'segmentation-id={seg_id}'.format(
267
+ seg_id=subport['segmentation_id'],
268
+ seg_type=subport['segmentation_type'],
269
+ ),
274
270
  self.new_trunk.name,
275
271
  ]
276
272
  verifylist = [
@@ -585,7 +581,7 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
585
581
 
586
582
  def _test_set_network_trunk_attr(self, attr, value):
587
583
  arglist = [
588
- '--%s' % attr,
584
+ f'--{attr}',
589
585
  value,
590
586
  self._trunk[attr],
591
587
  ]
@@ -674,13 +670,12 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
674
670
  subport = self._trunk['sub_ports'][0]
675
671
  arglist = [
676
672
  '--subport',
677
- 'port=%(port)s,segmentation-type=%(seg_type)s,'
678
- 'segmentation-id=%(seg_id)s'
679
- % {
680
- 'seg_id': subport['segmentation_id'],
681
- 'seg_type': subport['segmentation_type'],
682
- 'port': subport['port_id'],
683
- },
673
+ 'port={port},segmentation-type={seg_type},'
674
+ 'segmentation-id={seg_id}'.format(
675
+ seg_id=subport['segmentation_id'],
676
+ seg_type=subport['segmentation_type'],
677
+ port=subport['port_id'],
678
+ ),
684
679
  self._trunk['name'],
685
680
  ]
686
681
  verifylist = [
@@ -732,12 +727,10 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
732
727
  subport = self._trunk['sub_ports'][0]
733
728
  arglist = [
734
729
  '--subport',
735
- 'segmentation-type=%(seg_type)s,'
736
- 'segmentation-id=%(seg_id)s'
737
- % {
738
- 'seg_id': subport['segmentation_id'],
739
- 'seg_type': subport['segmentation_type'],
740
- },
730
+ 'segmentation-type={seg_type},' 'segmentation-id={seg_id}'.format(
731
+ seg_id=subport['segmentation_id'],
732
+ seg_type=subport['segmentation_type'],
733
+ ),
741
734
  self._trunk['name'],
742
735
  ]
743
736
  verifylist = [
@@ -776,7 +769,8 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
776
769
  with testtools.ExpectedException(exceptions.CommandError) as e:
777
770
  self.cmd.take_action(parsed_args)
778
771
  self.assertEqual(
779
- "Failed to set trunk '%s': " % self._trunk['name'], str(e)
772
+ "Failed to set trunk '{}': ".format(self._trunk['name']),
773
+ str(e),
780
774
  )
781
775
  attrs = {'name': 'reallylongname'}
782
776
  self.network_client.update_trunk.assert_called_once_with(
@@ -805,7 +799,9 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
805
799
  with testtools.ExpectedException(exceptions.CommandError) as e:
806
800
  self.cmd.take_action(parsed_args)
807
801
  self.assertEqual(
808
- "Failed to add subports to trunk '%s': " % self._trunk['name'],
802
+ "Failed to add subports to trunk '{}': ".format(
803
+ self._trunk['name']
804
+ ),
809
805
  str(e),
810
806
  )
811
807
  self.network_client.update_trunk.assert_called_once_with(self._trunk)