Skip to content

Commit 9f71b77

Browse files
author
Tang Chen
committed
Identity: Fix DisplayCommandBase comments for cliff ShowOne subclass tests
As bug #1477199 describes, the wrong comment below is all over the unit test code of OSC. # DisplayCommandBase.take_action() returns two tuples There is no such class named DisplayCommandBase in OSC. It is in cliff. All OSC command classes inherit from the base classes in cliff, class Command, class Lister and class ShowOne. It is like this: Object |--> Command |--> DisplayCommandBase |--> Lister |--> ShowOne take_action() is an abstract method of class Command, and generally is overwritten by subclasses. * Command.take_action() returns nothing. * Lister.take_action() returns a tuple which contains a tuple of columns and a generator used to generate the data. * ShowOne.take_action() returns an iterator which contains a tuple of columns and a tuple of data. So, this problem should be fixed in 3 steps: 1. Remove all DisplayCommandBase comments for tests of classes inheriting from class Command in cliff as it returns nothing. 2. Fix all DisplayCommandBase comments for tests of classes inheriting from class Lister in cliff. Lister.take_action() returns a tuple and a generator. 3. Fix all DisplayCommandBase comments for tests of classes inheriting from class ShowOne in cliff. ShowOne.take_action() returns two tuples. This patch finishes step 3 in all identity tests. Change-Id: I1f05e833cdacd30915954e4220b6e1f16ac1ed40 Closes-bug: #1477199
1 parent d0c0cef commit 9f71b77

17 files changed

Lines changed: 225 additions & 75 deletions

openstackclient/tests/identity/v2_0/test_catalog.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ def test_catalog_show(self):
150150
]
151151
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
152152

153-
# DisplayCommandBase.take_action() returns two tuples
153+
# In base command class ShowOne in cliff, abstract method take_action()
154+
# returns a two-part tuple with a tuple of column names and a tuple of
155+
# data to be shown.
154156
columns, data = self.cmd.take_action(parsed_args)
155157
self.sc_mock.service_catalog.get_data.assert_called_with()
156158

openstackclient/tests/identity/v2_0/test_endpoint.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def test_endpoint_create(self):
6969
]
7070
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
7171

72-
# DisplayCommandBase.take_action() returns two tuples
72+
# In base command class ShowOne in cliff, abstract method take_action()
73+
# returns a two-part tuple with a tuple of column names and a tuple of
74+
# data to be shown.
7375
columns, data = self.cmd.take_action(parsed_args)
7476

7577
# EndpointManager.create(region, service_id, publicurl, adminurl,
@@ -243,7 +245,9 @@ def test_endpoint_show(self):
243245
]
244246
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
245247

246-
# DisplayCommandBase.take_action() returns two tuples
248+
# In base command class ShowOne in cliff, abstract method take_action()
249+
# returns a two-part tuple with a tuple of column names and a tuple of
250+
# data to be shown.
247251
columns, data = self.cmd.take_action(parsed_args)
248252

249253
# EndpointManager.list()

openstackclient/tests/identity/v2_0/test_project.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ def test_project_create_no_options(self):
7070
]
7171
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
7272

73-
# DisplayCommandBase.take_action() returns two tuples
73+
# In base command class ShowOne in cliff, abstract method take_action()
74+
# returns a two-part tuple with a tuple of column names and a tuple of
75+
# data to be shown.
7476
columns, data = self.cmd.take_action(parsed_args)
7577

7678
# Set expected values
@@ -96,7 +98,9 @@ def test_project_create_description(self):
9698
]
9799
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
98100

99-
# DisplayCommandBase.take_action() returns two tuples
101+
# In base command class ShowOne in cliff, abstract method take_action()
102+
# returns a two-part tuple with a tuple of column names and a tuple of
103+
# data to be shown.
100104
columns, data = self.cmd.take_action(parsed_args)
101105

102106
# Set expected values
@@ -124,7 +128,9 @@ def test_project_create_enable(self):
124128
]
125129
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
126130

127-
# DisplayCommandBase.take_action() returns two tuples
131+
# In base command class ShowOne in cliff, abstract method take_action()
132+
# returns a two-part tuple with a tuple of column names and a tuple of
133+
# data to be shown.
128134
columns, data = self.cmd.take_action(parsed_args)
129135

130136
# Set expected values
@@ -152,7 +158,9 @@ def test_project_create_disable(self):
152158
]
153159
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
154160

155-
# DisplayCommandBase.take_action() returns two tuples
161+
# In base command class ShowOne in cliff, abstract method take_action()
162+
# returns a two-part tuple with a tuple of column names and a tuple of
163+
# data to be shown.
156164
columns, data = self.cmd.take_action(parsed_args)
157165

158166
# Set expected values
@@ -180,7 +188,9 @@ def test_project_create_property(self):
180188
]
181189
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
182190

183-
# DisplayCommandBase.take_action() returns two tuples
191+
# In base command class ShowOne in cliff, abstract method take_action()
192+
# returns a two-part tuple with a tuple of column names and a tuple of
193+
# data to be shown.
184194
columns, data = self.cmd.take_action(parsed_args)
185195

186196
# Set expected values
@@ -221,7 +231,9 @@ def _raise_conflict(*args, **kwargs):
221231
]
222232
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
223233

224-
# DisplayCommandBase.take_action() returns two tuples
234+
# In base command class ShowOne in cliff, abstract method take_action()
235+
# returns a two-part tuple with a tuple of column names and a tuple of
236+
# data to be shown.
225237
columns, data = self.cmd.take_action(parsed_args)
226238

227239
# ProjectManager.create(name, description, enabled)
@@ -251,7 +263,9 @@ def test_project_create_or_show_not_exists(self):
251263
]
252264
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
253265

254-
# DisplayCommandBase.take_action() returns two tuples
266+
# In base command class ShowOne in cliff, abstract method take_action()
267+
# returns a two-part tuple with a tuple of column names and a tuple of
268+
# data to be shown.
255269
columns, data = self.cmd.take_action(parsed_args)
256270

257271
# Set expected values
@@ -553,7 +567,9 @@ def test_project_show(self):
553567
]
554568
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
555569

556-
# DisplayCommandBase.take_action() returns two tuples
570+
# In base command class ShowOne in cliff, abstract method take_action()
571+
# returns a two-part tuple with a tuple of column names and a tuple of
572+
# data to be shown.
557573
columns, data = self.cmd.take_action(parsed_args)
558574
self.projects_mock.get.assert_called_with(
559575
identity_fakes.project_id,

openstackclient/tests/identity/v2_0/test_role.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def test_role_add(self):
8686
]
8787
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
8888

89-
# DisplayCommandBase.take_action() returns two tuples
89+
# In base command class ShowOne in cliff, abstract method take_action()
90+
# returns a two-part tuple with a tuple of column names and a tuple of
91+
# data to be shown.
9092
columns, data = self.cmd.take_action(parsed_args)
9193

9294
# RoleManager.add_user_role(user, role, tenant=None)
@@ -137,7 +139,9 @@ def test_role_create_no_options(self):
137139
]
138140
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
139141

140-
# DisplayCommandBase.take_action() returns two tuples
142+
# In base command class ShowOne in cliff, abstract method take_action()
143+
# returns a two-part tuple with a tuple of column names and a tuple of
144+
# data to be shown.
141145
columns, data = self.cmd.take_action(parsed_args)
142146

143147
# RoleManager.create(name)
@@ -171,7 +175,9 @@ def _raise_conflict(*args, **kwargs):
171175
]
172176
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
173177

174-
# DisplayCommandBase.take_action() returns two tuples
178+
# In base command class ShowOne in cliff, abstract method take_action()
179+
# returns a two-part tuple with a tuple of column names and a tuple of
180+
# data to be shown.
175181
columns, data = self.cmd.take_action(parsed_args)
176182

177183
# RoleManager.get(name, description, enabled)
@@ -196,7 +202,9 @@ def test_role_create_or_show_not_exists(self):
196202
]
197203
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
198204

199-
# DisplayCommandBase.take_action() returns two tuples
205+
# In base command class ShowOne in cliff, abstract method take_action()
206+
# returns a two-part tuple with a tuple of column names and a tuple of
207+
# data to be shown.
200208
columns, data = self.cmd.take_action(parsed_args)
201209

202210
# RoleManager.create(name)
@@ -484,7 +492,9 @@ def test_service_show(self):
484492
]
485493
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
486494

487-
# DisplayCommandBase.take_action() returns two tuples
495+
# In base command class ShowOne in cliff, abstract method take_action()
496+
# returns a two-part tuple with a tuple of column names and a tuple of
497+
# data to be shown.
488498
columns, data = self.cmd.take_action(parsed_args)
489499

490500
# RoleManager.get(role)

openstackclient/tests/identity/v2_0/test_service.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def test_service_create_with_type_positional(self):
6969
]
7070
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
7171

72-
# DisplayCommandBase.take_action() returns two tuples
72+
# In base command class ShowOne in cliff, abstract method take_action()
73+
# returns a two-part tuple with a tuple of column names and a tuple of
74+
# data to be shown.
7375
columns, data = self.cmd.take_action(parsed_args)
7476

7577
# ServiceManager.create(name, service_type, description)
@@ -95,7 +97,9 @@ def test_service_create_with_type_option(self):
9597
]
9698
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
9799

98-
# DisplayCommandBase.take_action() returns two tuples
100+
# In base command class ShowOne in cliff, abstract method take_action()
101+
# returns a two-part tuple with a tuple of column names and a tuple of
102+
# data to be shown.
99103
columns, data = self.cmd.take_action(parsed_args)
100104

101105
# ServiceManager.create(name, service_type, description)
@@ -121,7 +125,9 @@ def test_service_create_with_name_option(self):
121125
]
122126
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
123127

124-
# DisplayCommandBase.take_action() returns two tuples
128+
# In base command class ShowOne in cliff, abstract method take_action()
129+
# returns a two-part tuple with a tuple of column names and a tuple of
130+
# data to be shown.
125131
columns, data = self.cmd.take_action(parsed_args)
126132

127133
# ServiceManager.create(name, service_type, description)
@@ -148,7 +154,9 @@ def test_service_create_description(self):
148154
]
149155
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
150156

151-
# DisplayCommandBase.take_action() returns two tuples
157+
# In base command class ShowOne in cliff, abstract method take_action()
158+
# returns a two-part tuple with a tuple of column names and a tuple of
159+
# data to be shown.
152160
columns, data = self.cmd.take_action(parsed_args)
153161

154162
# ServiceManager.create(name, service_type, description)
@@ -280,7 +288,9 @@ def test_service_show(self):
280288
]
281289
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
282290

283-
# DisplayCommandBase.take_action() returns two tuples
291+
# In base command class ShowOne in cliff, abstract method take_action()
292+
# returns a two-part tuple with a tuple of column names and a tuple of
293+
# data to be shown.
284294
columns, data = self.cmd.take_action(parsed_args)
285295

286296
# ServiceManager.get(id)

openstackclient/tests/identity/v2_0/test_token.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def test_token_issue(self):
4343
verifylist = []
4444
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
4545

46-
# DisplayCommandBase.take_action() returns two tuples
46+
# In base command class ShowOne in cliff, abstract method take_action()
47+
# returns a two-part tuple with a tuple of column names and a tuple of
48+
# data to be shown.
4749
columns, data = self.cmd.take_action(parsed_args)
4850

4951
self.sc_mock.get_token.assert_called_with()

openstackclient/tests/identity/v2_0/test_user.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def test_user_create_no_options(self):
8383
]
8484
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
8585

86-
# DisplayCommandBase.take_action() returns two tuples
86+
# In base command class ShowOne in cliff, abstract method take_action()
87+
# returns a two-part tuple with a tuple of column names and a tuple of
88+
# data to be shown.
8789
columns, data = self.cmd.take_action(parsed_args)
8890

8991
# Set expected values
@@ -114,7 +116,9 @@ def test_user_create_password(self):
114116
]
115117
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
116118

117-
# DisplayCommandBase.take_action() returns two tuples
119+
# In base command class ShowOne in cliff, abstract method take_action()
120+
# returns a two-part tuple with a tuple of column names and a tuple of
121+
# data to be shown.
118122
columns, data = self.cmd.take_action(parsed_args)
119123

120124
# Set expected values
@@ -143,7 +147,9 @@ def test_user_create_password_prompt(self):
143147
]
144148
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
145149

146-
# DisplayCommandBase.take_action() returns two tuples
150+
# In base command class ShowOne in cliff, abstract method take_action()
151+
# returns a two-part tuple with a tuple of column names and a tuple of
152+
# data to be shown.
147153
mocker = mock.Mock()
148154
mocker.return_value = 'abc123'
149155
with mock.patch("openstackclient.common.utils.get_password", mocker):
@@ -176,7 +182,9 @@ def test_user_create_email(self):
176182
]
177183
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
178184

179-
# DisplayCommandBase.take_action() returns two tuples
185+
# In base command class ShowOne in cliff, abstract method take_action()
186+
# returns a two-part tuple with a tuple of column names and a tuple of
187+
# data to be shown.
180188
columns, data = self.cmd.take_action(parsed_args)
181189

182190
# Set expected values
@@ -221,7 +229,9 @@ def test_user_create_project(self):
221229
]
222230
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
223231

224-
# DisplayCommandBase.take_action() returns two tuples
232+
# In base command class ShowOne in cliff, abstract method take_action()
233+
# returns a two-part tuple with a tuple of column names and a tuple of
234+
# data to be shown.
225235
columns, data = self.cmd.take_action(parsed_args)
226236

227237
# Set expected values
@@ -259,7 +269,9 @@ def test_user_create_enable(self):
259269
]
260270
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
261271

262-
# DisplayCommandBase.take_action() returns two tuples
272+
# In base command class ShowOne in cliff, abstract method take_action()
273+
# returns a two-part tuple with a tuple of column names and a tuple of
274+
# data to be shown.
263275
columns, data = self.cmd.take_action(parsed_args)
264276

265277
# Set expected values
@@ -290,7 +302,9 @@ def test_user_create_disable(self):
290302
]
291303
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
292304

293-
# DisplayCommandBase.take_action() returns two tuples
305+
# In base command class ShowOne in cliff, abstract method take_action()
306+
# returns a two-part tuple with a tuple of column names and a tuple of
307+
# data to be shown.
294308
columns, data = self.cmd.take_action(parsed_args)
295309

296310
# Set expected values
@@ -332,7 +346,9 @@ def _raise_conflict(*args, **kwargs):
332346
]
333347
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
334348

335-
# DisplayCommandBase.take_action() returns two tuples
349+
# In base command class ShowOne in cliff, abstract method take_action()
350+
# returns a two-part tuple with a tuple of column names and a tuple of
351+
# data to be shown.
336352
columns, data = self.cmd.take_action(parsed_args)
337353

338354
# UserManager.create(name, password, email, tenant_id=, enabled=)
@@ -352,7 +368,9 @@ def test_user_create_or_show_not_exists(self):
352368
]
353369
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
354370

355-
# DisplayCommandBase.take_action() returns two tuples
371+
# In base command class ShowOne in cliff, abstract method take_action()
372+
# returns a two-part tuple with a tuple of column names and a tuple of
373+
# data to be shown.
356374
columns, data = self.cmd.take_action(parsed_args)
357375

358376
# Set expected values
@@ -758,7 +776,9 @@ def test_user_show(self):
758776
]
759777
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
760778

761-
# DisplayCommandBase.take_action() returns two tuples
779+
# In base command class ShowOne in cliff, abstract method take_action()
780+
# returns a two-part tuple with a tuple of column names and a tuple of
781+
# data to be shown.
762782
columns, data = self.cmd.take_action(parsed_args)
763783

764784
self.users_mock.get.assert_called_with(identity_fakes.user_id)

openstackclient/tests/identity/v3/test_catalog.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ def test_catalog_show(self):
103103
]
104104
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
105105

106-
# DisplayCommandBase.take_action() returns two tuples
106+
# In base command class ShowOne in cliff, abstract method take_action()
107+
# returns a two-part tuple with a tuple of column names and a tuple of
108+
# data to be shown.
107109
columns, data = self.cmd.take_action(parsed_args)
108110
self.sc_mock.service_catalog.get_data.assert_called_with()
109111

0 commit comments

Comments
 (0)