Skip to content
This repository was archived by the owner on Nov 19, 2018. It is now read-only.

Commit e69b88e

Browse files
author
Tang Chen
committed
Fix DisplayCommandBase comments for cliff Lister 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 2 in all but identity tests. There are too many such comments in identity tests. So fix them all in another patch. Change-Id: I00f38d12f55abe20fa708f6349073da658622f8d Partial-bug: #1477199
1 parent 43f8050 commit e69b88e

11 files changed

Lines changed: 138 additions & 46 deletions

File tree

openstackclient/tests/common/test_availability_zone.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ def test_availability_zone_list_no_options(self):
144144
verifylist = []
145145
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
146146

147-
# DisplayCommandBase.take_action() returns two tuples
147+
# In base command class Lister in cliff, abstract method take_action()
148+
# returns a tuple containing the column names and an iterable
149+
# containing the data to be listed.
148150
columns, data = self.cmd.take_action(parsed_args)
149151

150152
self.compute_azs_mock.list.assert_called_with()
@@ -170,7 +172,9 @@ def test_availability_zone_list_long(self):
170172
]
171173
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
172174

173-
# DisplayCommandBase.take_action() returns two tuples
175+
# In base command class Lister in cliff, abstract method take_action()
176+
# returns a tuple containing the column names and an iterable
177+
# containing the data to be listed.
174178
columns, data = self.cmd.take_action(parsed_args)
175179

176180
self.compute_azs_mock.list.assert_called_with()
@@ -199,7 +203,9 @@ def test_availability_zone_list_compute(self):
199203
]
200204
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
201205

202-
# DisplayCommandBase.take_action() returns two tuples
206+
# In base command class Lister in cliff, abstract method take_action()
207+
# returns a tuple containing the column names and an iterable
208+
# containing the data to be listed.
203209
columns, data = self.cmd.take_action(parsed_args)
204210

205211
self.compute_azs_mock.list.assert_called_with()
@@ -221,7 +227,9 @@ def test_availability_zone_list_volume(self):
221227
]
222228
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
223229

224-
# DisplayCommandBase.take_action() returns two tuples
230+
# In base command class Lister in cliff, abstract method take_action()
231+
# returns a tuple containing the column names and an iterable
232+
# containing the data to be listed.
225233
columns, data = self.cmd.take_action(parsed_args)
226234

227235
self.compute_azs_mock.list.assert_not_called()
@@ -243,7 +251,9 @@ def test_availability_zone_list_network(self):
243251
]
244252
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
245253

246-
# DisplayCommandBase.take_action() returns two tuples
254+
# In base command class Lister in cliff, abstract method take_action()
255+
# returns a tuple containing the column names and an iterable
256+
# containing the data to be listed.
247257
columns, data = self.cmd.take_action(parsed_args)
248258

249259
self.compute_azs_mock.list.assert_not_called()

openstackclient/tests/common/test_extension.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def test_extension_list_no_options(self):
6363
verifylist = []
6464
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
6565

66-
# DisplayCommandBase.take_action() returns two tuples
66+
# In base command class Lister in cliff, abstract method take_action()
67+
# returns a tuple containing the column names and an iterable
68+
# containing the data to be listed.
6769
columns, data = self.cmd.take_action(parsed_args)
6870

6971
# no args should output from all services
@@ -93,7 +95,9 @@ def test_extension_list_long(self):
9395
]
9496
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
9597

96-
# DisplayCommandBase.take_action() returns two tuples
98+
# In base command class Lister in cliff, abstract method take_action()
99+
# returns a tuple containing the column names and an iterable
100+
# containing the data to be listed.
97101
columns, data = self.cmd.take_action(parsed_args)
98102

99103
# no args should output from all services
@@ -131,7 +135,9 @@ def test_extension_list_identity(self):
131135
]
132136
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
133137

134-
# DisplayCommandBase.take_action() returns two tuples
138+
# In base command class Lister in cliff, abstract method take_action()
139+
# returns a tuple containing the column names and an iterable
140+
# containing the data to be listed.
135141
columns, data = self.cmd.take_action(parsed_args)
136142

137143
self.identity_extensions_mock.list.assert_called_with()

openstackclient/tests/common/test_module.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def test_command_list_no_options(self):
6262
verifylist = []
6363
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
6464

65-
# DisplayCommandBase.take_action() returns two tuples
65+
# In base command class Lister in cliff, abstract method take_action()
66+
# returns a tuple containing the column names and an iterable
67+
# containing the data to be listed.
6668
columns, data = self.cmd.take_action(parsed_args)
6769

6870
collist = ('Command Group', 'Commands')
@@ -94,7 +96,9 @@ def test_module_list_no_options(self):
9496
]
9597
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
9698

97-
# DisplayCommandBase.take_action() returns two tuples
99+
# In base command class Lister in cliff, abstract method take_action()
100+
# returns a tuple containing the column names and an iterable
101+
# containing the data to be listed.
98102
columns, data = self.cmd.take_action(parsed_args)
99103

100104
# Additional modules may be present, just check our additions
@@ -110,7 +114,9 @@ def test_module_list_all(self):
110114
]
111115
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
112116

113-
# DisplayCommandBase.take_action() returns two tuples
117+
# In base command class Lister in cliff, abstract method take_action()
118+
# returns a tuple containing the column names and an iterable
119+
# containing the data to be listed.
114120
columns, data = self.cmd.take_action(parsed_args)
115121

116122
# Additional modules may be present, just check our additions

openstackclient/tests/common/test_timing.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def test_timing_list_no_data(self):
6161
verifylist = []
6262
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
6363

64-
# DisplayCommandBase.take_action() returns two tuples
64+
# In base command class Lister in cliff, abstract method take_action()
65+
# returns a tuple containing the column names and an iterable
66+
# containing the data to be listed.
6567
columns, data = self.cmd.take_action(parsed_args)
6668

6769
self.assertEqual(self.columns, columns)
@@ -80,7 +82,9 @@ def test_timing_list(self):
8082
verifylist = []
8183
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
8284

83-
# DisplayCommandBase.take_action() returns two tuples
85+
# In base command class Lister in cliff, abstract method take_action()
86+
# returns a tuple containing the column names and an iterable
87+
# containing the data to be listed.
8488
columns, data = self.cmd.take_action(parsed_args)
8589
self.assertEqual(self.columns, columns)
8690
datalist = [

openstackclient/tests/image/v1/test_image.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ def test_image_list_no_options(self):
273273
]
274274
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
275275

276-
# DisplayCommandBase.take_action() returns two tuples
276+
# In base command class Lister in cliff, abstract method take_action()
277+
# returns a tuple containing the column names and an iterable
278+
# containing the data to be listed.
277279
columns, data = self.cmd.take_action(parsed_args)
278280
self.api_mock.image_list.assert_called_with(
279281
detailed=True,
@@ -294,7 +296,9 @@ def test_image_list_public_option(self):
294296
]
295297
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
296298

297-
# DisplayCommandBase.take_action() returns two tuples
299+
# In base command class Lister in cliff, abstract method take_action()
300+
# returns a tuple containing the column names and an iterable
301+
# containing the data to be listed.
298302
columns, data = self.cmd.take_action(parsed_args)
299303
self.api_mock.image_list.assert_called_with(
300304
detailed=True,
@@ -316,7 +320,9 @@ def test_image_list_private_option(self):
316320
]
317321
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
318322

319-
# DisplayCommandBase.take_action() returns two tuples
323+
# In base command class Lister in cliff, abstract method take_action()
324+
# returns a tuple containing the column names and an iterable
325+
# containing the data to be listed.
320326
columns, data = self.cmd.take_action(parsed_args)
321327
self.api_mock.image_list.assert_called_with(
322328
detailed=True,
@@ -336,7 +342,9 @@ def test_image_list_long_option(self):
336342
]
337343
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
338344

339-
# DisplayCommandBase.take_action() returns two tuples
345+
# In base command class Lister in cliff, abstract method take_action()
346+
# returns a tuple containing the column names and an iterable
347+
# containing the data to be listed.
340348
columns, data = self.cmd.take_action(parsed_args)
341349
self.api_mock.image_list.assert_called_with(
342350
detailed=True,
@@ -385,7 +393,9 @@ def test_image_list_property_option(self, sf_mock):
385393
]
386394
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
387395

388-
# DisplayCommandBase.take_action() returns two tuples
396+
# In base command class Lister in cliff, abstract method take_action()
397+
# returns a tuple containing the column names and an iterable
398+
# containing the data to be listed.
389399
columns, data = self.cmd.take_action(parsed_args)
390400
self.api_mock.image_list.assert_called_with(
391401
detailed=True,
@@ -411,7 +421,9 @@ def test_image_list_sort_option(self, si_mock):
411421
verifylist = [('sort', 'name:asc')]
412422
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
413423

414-
# DisplayCommandBase.take_action() returns two tuples
424+
# In base command class Lister in cliff, abstract method take_action()
425+
# returns a tuple containing the column names and an iterable
426+
# containing the data to be listed.
415427
columns, data = self.cmd.take_action(parsed_args)
416428
self.api_mock.image_list.assert_called_with(
417429
detailed=True,

openstackclient/tests/image/v2/test_image.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,9 @@ def test_image_list_no_options(self):
495495
]
496496
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
497497

498-
# DisplayCommandBase.take_action() returns two tuples
498+
# In base command class Lister in cliff, abstract method take_action()
499+
# returns a tuple containing the column names and an iterable
500+
# containing the data to be listed.
499501
columns, data = self.cmd.take_action(parsed_args)
500502
self.api_mock.image_list.assert_called_with()
501503

@@ -514,7 +516,9 @@ def test_image_list_public_option(self):
514516
]
515517
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
516518

517-
# DisplayCommandBase.take_action() returns two tuples
519+
# In base command class Lister in cliff, abstract method take_action()
520+
# returns a tuple containing the column names and an iterable
521+
# containing the data to be listed.
518522
columns, data = self.cmd.take_action(parsed_args)
519523
self.api_mock.image_list.assert_called_with(
520524
public=True,
@@ -535,7 +539,9 @@ def test_image_list_private_option(self):
535539
]
536540
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
537541

538-
# DisplayCommandBase.take_action() returns two tuples
542+
# In base command class Lister in cliff, abstract method take_action()
543+
# returns a tuple containing the column names and an iterable
544+
# containing the data to be listed.
539545
columns, data = self.cmd.take_action(parsed_args)
540546
self.api_mock.image_list.assert_called_with(
541547
private=True,
@@ -556,7 +562,9 @@ def test_image_list_shared_option(self):
556562
]
557563
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
558564

559-
# DisplayCommandBase.take_action() returns two tuples
565+
# In base command class Lister in cliff, abstract method take_action()
566+
# returns a tuple containing the column names and an iterable
567+
# containing the data to be listed.
560568
columns, data = self.cmd.take_action(parsed_args)
561569
self.api_mock.image_list.assert_called_with(
562570
shared=True,
@@ -574,7 +582,9 @@ def test_image_list_long_option(self):
574582
]
575583
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
576584

577-
# DisplayCommandBase.take_action() returns two tuples
585+
# In base command class Lister in cliff, abstract method take_action()
586+
# returns a tuple containing the column names and an iterable
587+
# containing the data to be listed.
578588
columns, data = self.cmd.take_action(parsed_args)
579589
self.api_mock.image_list.assert_called_with()
580590

@@ -620,7 +630,9 @@ def test_image_list_property_option(self, sf_mock):
620630
]
621631
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
622632

623-
# DisplayCommandBase.take_action() returns two tuples
633+
# In base command class Lister in cliff, abstract method take_action()
634+
# returns a tuple containing the column names and an iterable
635+
# containing the data to be listed.
624636
columns, data = self.cmd.take_action(parsed_args)
625637
self.api_mock.image_list.assert_called_with()
626638
sf_mock.assert_called_with(
@@ -643,7 +655,9 @@ def test_image_list_sort_option(self, si_mock):
643655
verifylist = [('sort', 'name:asc')]
644656
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
645657

646-
# DisplayCommandBase.take_action() returns two tuples
658+
# In base command class Lister in cliff, abstract method take_action()
659+
# returns a tuple containing the column names and an iterable
660+
# containing the data to be listed.
647661
columns, data = self.cmd.take_action(parsed_args)
648662
self.api_mock.image_list.assert_called_with()
649663
si_mock.assert_called_with(

openstackclient/tests/network/v2/test_network.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ def test_network_list_no_options(self):
380380
]
381381
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
382382

383-
# DisplayCommandBase.take_action() returns two tuples
383+
# In base command class Lister in cliff, abstract method take_action()
384+
# returns a tuple containing the column names and an iterable
385+
# containing the data to be listed.
384386
columns, data = self.cmd.take_action(parsed_args)
385387

386388
self.network.networks.assert_called_with()
@@ -397,7 +399,9 @@ def test_list_external(self):
397399
]
398400
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
399401

400-
# DisplayCommandBase.take_action() returns two tuples
402+
# In base command class Lister in cliff, abstract method take_action()
403+
# returns a tuple containing the column names and an iterable
404+
# containing the data to be listed.
401405
columns, data = self.cmd.take_action(parsed_args)
402406

403407
self.network.networks.assert_called_with(
@@ -416,7 +420,9 @@ def test_network_list_long(self):
416420
]
417421
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
418422

419-
# DisplayCommandBase.take_action() returns two tuples
423+
# In base command class Lister in cliff, abstract method take_action()
424+
# returns a tuple containing the column names and an iterable
425+
# containing the data to be listed.
420426
columns, data = self.cmd.take_action(parsed_args)
421427

422428
self.network.networks.assert_called_with()

openstackclient/tests/network/v2/test_router.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def test_router_list_no_options(self):
201201
]
202202
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
203203

204-
# DisplayCommandBase.take_action() returns two tuples
204+
# In base command class Lister in cliff, abstract method take_action()
205+
# returns a tuple containing the column names and an iterable
206+
# containing the data to be listed.
205207
columns, data = self.cmd.take_action(parsed_args)
206208

207209
self.network.routers.assert_called_with()
@@ -217,7 +219,9 @@ def test_router_list_long(self):
217219
]
218220
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
219221

220-
# DisplayCommandBase.take_action() returns two tuples
222+
# In base command class Lister in cliff, abstract method take_action()
223+
# returns a tuple containing the column names and an iterable
224+
# containing the data to be listed.
221225
columns, data = self.cmd.take_action(parsed_args)
222226

223227
self.network.routers.assert_called_with()

0 commit comments

Comments
 (0)