Skip to content

Commit 23faa33

Browse files
author
Tang Chen
committed
Compute: 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 compute tests. Change-Id: I4df224ec82b5d82a3d6d3f366c0f68a7ea0d87cd Partial-bug: #1477199
1 parent 3c67e8d commit 23faa33

3 files changed

Lines changed: 36 additions & 12 deletions

File tree

openstackclient/tests/compute/v2/test_security_group.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ def test_security_group_create_no_options(self):
9090
]
9191
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
9292

93-
# DisplayCommandBase.take_action() returns two tuples
93+
# In base command class ShowOne in cliff, abstractmethod take_action()
94+
# returns a two-part tuple with a tuple of column names and a tuple of
95+
# data to be shown.
9496
columns, data = self.cmd.take_action(parsed_args)
9597

9698
# SecurityGroupManager.create(name, description)
@@ -113,7 +115,9 @@ def test_security_group_create_description(self):
113115
]
114116
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
115117

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

119123
# SecurityGroupManager.create(name, description)

openstackclient/tests/compute/v2/test_security_group_rule.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ def test_security_group_rule_create_no_options(self):
152152
]
153153
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
154154

155-
# DisplayCommandBase.take_action() returns two tuples
155+
# In base command class ShowOne in cliff, abstractmethod take_action()
156+
# returns a two-part tuple with a tuple of column names and a tuple of
157+
# data to be shown.
156158
columns, data = self.cmd.take_action(parsed_args)
157159

158160
# SecurityGroupManager.create(name, description)
@@ -196,7 +198,9 @@ def test_security_group_rule_create_ftp(self):
196198
]
197199
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
198200

199-
# DisplayCommandBase.take_action() returns two tuples
201+
# In base command class ShowOne in cliff, abstractmethod take_action()
202+
# returns a two-part tuple with a tuple of column names and a tuple of
203+
# data to be shown.
200204
columns, data = self.cmd.take_action(parsed_args)
201205

202206
# SecurityGroupManager.create(name, description)
@@ -244,7 +248,9 @@ def test_security_group_rule_create_ssh(self):
244248
]
245249
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
246250

247-
# DisplayCommandBase.take_action() returns two tuples
251+
# In base command class ShowOne in cliff, abstractmethod take_action()
252+
# returns a two-part tuple with a tuple of column names and a tuple of
253+
# data to be shown.
248254
columns, data = self.cmd.take_action(parsed_args)
249255

250256
# SecurityGroupManager.create(name, description)
@@ -287,7 +293,9 @@ def test_security_group_rule_create_udp(self):
287293
]
288294
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
289295

290-
# DisplayCommandBase.take_action() returns two tuples
296+
# In base command class ShowOne in cliff, abstractmethod take_action()
297+
# returns a two-part tuple with a tuple of column names and a tuple of
298+
# data to be shown.
291299
columns, data = self.cmd.take_action(parsed_args)
292300

293301
# SecurityGroupManager.create(name, description)
@@ -333,7 +341,9 @@ def test_security_group_rule_create_icmp(self):
333341
]
334342
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
335343

336-
# DisplayCommandBase.take_action() returns two tuples
344+
# In base command class ShowOne in cliff, abstractmethod take_action()
345+
# returns a two-part tuple with a tuple of column names and a tuple of
346+
# data to be shown.
337347
columns, data = self.cmd.take_action(parsed_args)
338348

339349
# SecurityGroupManager.create(name, description)

openstackclient/tests/compute/v2/test_server.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ def test_server_create_minimal(self):
163163
]
164164
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
165165

166-
# DisplayCommandBase.take_action() returns two tuples
166+
# In base command class ShowOne in cliff, abstractmethod take_action()
167+
# returns a two-part tuple with a tuple of column names and a tuple of
168+
# data to be shown.
167169
columns, data = self.cmd.take_action(parsed_args)
168170

169171
# Set expected values
@@ -241,7 +243,9 @@ def test_server_create_with_network(self):
241243
self.app.client_manager.network.find_network = find_network
242244
self.app.client_manager.network.find_port = find_port
243245

244-
# DisplayCommandBase.take_action() returns two tuples
246+
# In base command class ShowOne in cliff, abstractmethod take_action()
247+
# returns a two-part tuple with a tuple of column names and a tuple of
248+
# data to be shown.
245249
columns, data = self.cmd.take_action(parsed_args)
246250

247251
# Set expected values
@@ -299,7 +303,9 @@ def test_server_create_userdata(self, mock_open):
299303
]
300304
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
301305

302-
# DisplayCommandBase.take_action() returns two tuples
306+
# In base command class ShowOne in cliff, abstractmethod take_action()
307+
# returns a two-part tuple with a tuple of column names and a tuple of
308+
# data to be shown.
303309
columns, data = self.cmd.take_action(parsed_args)
304310

305311
# Ensure the userdata file is opened
@@ -551,7 +557,9 @@ def test_server_image_create_no_options(self):
551557
]
552558
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
553559

554-
# DisplayCommandBase.take_action() returns two tuples
560+
# In base command class ShowOne in cliff, abstractmethod take_action()
561+
# returns a two-part tuple with a tuple of column names and a tuple of
562+
# data to be shown.
555563
columns, data = self.cmd.take_action(parsed_args)
556564

557565
# ServerManager.create_image(server, image_name, metadata=)
@@ -574,7 +582,9 @@ def test_server_image_create_name(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 ShowOne in cliff, abstractmethod take_action()
586+
# returns a two-part tuple with a tuple of column names and a tuple of
587+
# data to be shown.
578588
columns, data = self.cmd.take_action(parsed_args)
579589

580590
# ServerManager.create_image(server, image_name, metadata=)

0 commit comments

Comments
 (0)