Use FakeVolume in server test cases.
We have a class FakeVolume to fake one or more volumes. So use it in test_server.py. Change-Id: I735ae7f678a6799e0ae4c7c25c8083d9ebf47b09 Implements: blueprint improve-volume-unittest-framework
This commit is contained in:
parent
a4696dce1e
commit
ec79d338f7
@ -76,8 +76,6 @@ QUOTA = {
|
||||
QUOTA_columns = tuple(sorted(QUOTA))
|
||||
QUOTA_data = tuple(QUOTA[x] for x in sorted(QUOTA))
|
||||
|
||||
block_device_mapping = 'vda=' + volume_fakes.volume_name + ':::0'
|
||||
|
||||
service_host = 'host_test'
|
||||
service_binary = 'compute_test'
|
||||
service_status = 'enabled'
|
||||
|
@ -13,7 +13,6 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import copy
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
@ -22,7 +21,6 @@ from openstackclient.common import exceptions
|
||||
from openstackclient.common import utils as common_utils
|
||||
from openstackclient.compute.v2 import server
|
||||
from openstackclient.tests.compute.v2 import fakes as compute_fakes
|
||||
from openstackclient.tests import fakes
|
||||
from openstackclient.tests.image.v2 import fakes as image_fakes
|
||||
from openstackclient.tests import utils
|
||||
from openstackclient.tests.volume.v2 import fakes as volume_fakes
|
||||
@ -113,12 +111,9 @@ class TestServerCreate(TestServer):
|
||||
self.flavor = compute_fakes.FakeFlavor.create_one_flavor()
|
||||
self.flavors_mock.get.return_value = self.flavor
|
||||
|
||||
self.volume = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(volume_fakes.VOLUME),
|
||||
loaded=True,
|
||||
)
|
||||
self.volume = volume_fakes.FakeVolume.create_one_volume()
|
||||
self.volumes_mock.get.return_value = self.volume
|
||||
self.block_device_mapping = 'vda=' + self.volume.name + ':::0'
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = server.CreateServer(self.app, None)
|
||||
@ -357,13 +352,13 @@ class TestServerCreate(TestServer):
|
||||
arglist = [
|
||||
'--image', 'image1',
|
||||
'--flavor', self.flavor.id,
|
||||
'--block-device-mapping', compute_fakes.block_device_mapping,
|
||||
'--block-device-mapping', self.block_device_mapping,
|
||||
self.new_server.name,
|
||||
]
|
||||
verifylist = [
|
||||
('image', 'image1'),
|
||||
('flavor', self.flavor.id),
|
||||
('block_device_mapping', [compute_fakes.block_device_mapping]),
|
||||
('block_device_mapping', [self.block_device_mapping]),
|
||||
('config_drive', False),
|
||||
('server_name', self.new_server.name),
|
||||
]
|
||||
@ -373,9 +368,9 @@ class TestServerCreate(TestServer):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
real_volume_mapping = (
|
||||
(compute_fakes.block_device_mapping.split('=', 1)[1]).replace(
|
||||
volume_fakes.volume_name,
|
||||
volume_fakes.volume_id))
|
||||
(self.block_device_mapping.split('=', 1)[1]).replace(
|
||||
self.volume.name,
|
||||
self.volume.id))
|
||||
|
||||
# Set expected values
|
||||
kwargs = dict(
|
||||
|
Loading…
Reference in New Issue
Block a user