Clean up FakeClient classes in volume fakes
Put FakeTransferClient and FakeServiceClient classes into FakeVolumeClient class, I think we need not to create FakeClient classes for every objects, we can use only FakeVolumeClient for all volume objects. This can reduce repetition, unified codes and make codes look cleaner and easier. Change-Id: I2729ef0e80166f4d49ccd9a48b653e2f215e3bfe
This commit is contained in:
parent
684412ca4c
commit
8f07fec3f2
@ -129,25 +129,6 @@ QOS_WITH_ASSOCIATIONS = {
|
||||
}
|
||||
|
||||
|
||||
class FakeTransferClient(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
self.transfers = mock.Mock()
|
||||
self.transfers.resource_class = fakes.FakeResource(None, {})
|
||||
|
||||
|
||||
class TestTransfer(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTransfer, self).setUp()
|
||||
|
||||
self.app.client_manager.volume = FakeTransferClient(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN
|
||||
)
|
||||
|
||||
|
||||
class FakeTransfer(object):
|
||||
"""Fake one or more Transfer."""
|
||||
|
||||
@ -180,24 +161,6 @@ class FakeTransfer(object):
|
||||
return transfer
|
||||
|
||||
|
||||
class FakeServiceClient(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.services = mock.Mock()
|
||||
self.services.resource_class = fakes.FakeResource(None, {})
|
||||
|
||||
|
||||
class TestService(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestService, self).setUp()
|
||||
|
||||
self.app.client_manager.volume = FakeServiceClient(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN
|
||||
)
|
||||
|
||||
|
||||
class FakeService(object):
|
||||
"""Fake one or more Services."""
|
||||
|
||||
@ -290,6 +253,8 @@ class FakeVolumev1Client(object):
|
||||
self.qos_specs.resource_class = fakes.FakeResource(None, {})
|
||||
self.volume_types = mock.Mock()
|
||||
self.volume_types.resource_class = fakes.FakeResource(None, {})
|
||||
self.transfers = mock.Mock()
|
||||
self.transfers.resource_class = fakes.FakeResource(None, {})
|
||||
self.auth_token = kwargs['token']
|
||||
self.management_url = kwargs['endpoint']
|
||||
|
||||
|
@ -17,7 +17,7 @@ from openstackclient.tests.volume.v1 import fakes as service_fakes
|
||||
from openstackclient.volume.v1 import service
|
||||
|
||||
|
||||
class TestService(service_fakes.TestService):
|
||||
class TestService(service_fakes.TestVolumev1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestService, self).setUp()
|
||||
|
@ -17,7 +17,7 @@ from openstackclient.tests.volume.v1 import fakes as transfer_fakes
|
||||
from openstackclient.volume.v1 import volume_transfer_request
|
||||
|
||||
|
||||
class TestTransfer(transfer_fakes.TestTransfer):
|
||||
class TestTransfer(transfer_fakes.TestVolumev1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTransfer, self).setUp()
|
||||
|
@ -25,25 +25,6 @@ from openstackclient.tests.image.v2 import fakes as image_fakes
|
||||
from openstackclient.tests import utils
|
||||
|
||||
|
||||
class FakeTransferClient(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
self.transfers = mock.Mock()
|
||||
self.transfers.resource_class = fakes.FakeResource(None, {})
|
||||
|
||||
|
||||
class TestTransfer(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTransfer, self).setUp()
|
||||
|
||||
self.app.client_manager.volume = FakeTransferClient(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN
|
||||
)
|
||||
|
||||
|
||||
class FakeTransfer(object):
|
||||
"""Fake one or more Transfer."""
|
||||
|
||||
@ -108,24 +89,6 @@ class FakeTypeAccess(object):
|
||||
return type_access
|
||||
|
||||
|
||||
class FakeServiceClient(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.services = mock.Mock()
|
||||
self.services.resource_class = fakes.FakeResource(None, {})
|
||||
|
||||
|
||||
class TestService(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestService, self).setUp()
|
||||
|
||||
self.app.client_manager.volume = FakeServiceClient(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN
|
||||
)
|
||||
|
||||
|
||||
class FakeService(object):
|
||||
"""Fake one or more Services."""
|
||||
|
||||
@ -200,6 +163,10 @@ class FakeVolumeClient(object):
|
||||
self.qos_specs.resource_class = fakes.FakeResource(None, {})
|
||||
self.availability_zones = mock.Mock()
|
||||
self.availability_zones.resource_class = fakes.FakeResource(None, {})
|
||||
self.transfers = mock.Mock()
|
||||
self.transfers.resource_class = fakes.FakeResource(None, {})
|
||||
self.services = mock.Mock()
|
||||
self.services.resource_class = fakes.FakeResource(None, {})
|
||||
self.auth_token = kwargs['token']
|
||||
self.management_url = kwargs['endpoint']
|
||||
|
||||
|
@ -17,7 +17,7 @@ from openstackclient.tests.volume.v2 import fakes as service_fakes
|
||||
from openstackclient.volume.v2 import service
|
||||
|
||||
|
||||
class TestService(service_fakes.TestService):
|
||||
class TestService(service_fakes.TestVolume):
|
||||
|
||||
def setUp(self):
|
||||
super(TestService, self).setUp()
|
||||
|
@ -17,7 +17,7 @@ from openstackclient.tests.volume.v2 import fakes as transfer_fakes
|
||||
from openstackclient.volume.v2 import volume_transfer_request
|
||||
|
||||
|
||||
class TestTransfer(transfer_fakes.TestTransfer):
|
||||
class TestTransfer(transfer_fakes.TestVolume):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTransfer, self).setUp()
|
||||
|
Loading…
Reference in New Issue
Block a user