Some of the unit tests test run(), but not take_action().
For example, in openstackclient/tests/volume/v1/test_volume.py, there is:
def test_volume_set_size_smaller(self):
......
result = self.cmd.run(parsed_args)
self.assertEqual(0, result)
......
run() is defined in class Command in cliff. We don't need to test it in OSC
unit tests. On the contrary, we should test take_action(), which is
overwritten in each command classes in OSC.
Change-Id: If07e89953d40ac530f08cbb1ec05f5805171364b
Closes-bug: #1553468
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
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 identity tests.
Change-Id: I2929ee688b1d7afc52c6ab325982bdc24c60a995
Partial-bug: #1477199
columns and datalist has been set in each test case in compute,
which is not necessary. This patch abstract it out and remove
all redundant code.
Change-Id: I45a3582088161f12e60e7c933da8e7dcc0ae8e7b
Closes-Bug: #1532384
Currently v3 endpoint commands access service.name directly, while
name is not a required attribute of service. So if we associate an
endpoint to a service without name, we will get an AttributeError
executing v3 endpoint commands later. This patch addresses this
issue by checking if service.name is available before accessing it.
Change-Id: I3dd686ef02a2e21e2049a49cb55634385c2ecfaf
Closes-Bug: #1406737