diff options
| author | Jenkins <jenkins@review.openstack.org> | 2016-01-22 19:23:20 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2016-01-22 19:23:20 +0000 |
| commit | ee78fb2f782d3508cfa59df998d83f34963174ae (patch) | |
| tree | f8f1029fc043c73d68267d0012290aa2f7f157cd /openstackclient/tests/volume | |
| parent | 09be6a439a48c277af78346ce776de2df8830e98 (diff) | |
| parent | a8ec2ac49475c60c8e72a0fc3db6df778918bb49 (diff) | |
| download | python-openstackclient-ee78fb2f782d3508cfa59df998d83f34963174ae.tar.gz | |
Merge "Support listing volume availability zones"
Diffstat (limited to 'openstackclient/tests/volume')
| -rw-r--r-- | openstackclient/tests/volume/v2/fakes.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/openstackclient/tests/volume/v2/fakes.py b/openstackclient/tests/volume/v2/fakes.py index 60cec335..2e58e58d 100644 --- a/openstackclient/tests/volume/v2/fakes.py +++ b/openstackclient/tests/volume/v2/fakes.py @@ -202,6 +202,8 @@ class FakeVolumeClient(object): self.restores.resource_class = fakes.FakeResource(None, {}) self.qos_specs = mock.Mock() self.qos_specs.resource_class = fakes.FakeResource(None, {}) + self.availability_zones = mock.Mock() + self.availability_zones.resource_class = fakes.FakeResource(None, {}) self.auth_token = kwargs['token'] self.management_url = kwargs['endpoint'] @@ -304,3 +306,55 @@ class FakeVolume(object): volumes = FakeVolume.create_volumes(count) return mock.MagicMock(side_effect=volumes) + + +class FakeAvailabilityZone(object): + """Fake one or more volume availability zones (AZs).""" + + @staticmethod + def create_one_availability_zone(attrs={}, methods={}): + """Create a fake AZ. + + :param Dictionary attrs: + A dictionary with all attributes + :param Dictionary methods: + A dictionary with all methods + :return: + A FakeResource object with zoneName, zoneState, etc. + """ + # Set default attributes. + availability_zone = { + 'zoneName': uuid.uuid4().hex, + 'zoneState': {'available': True}, + } + + # Overwrite default attributes. + availability_zone.update(attrs) + + availability_zone = fakes.FakeResource( + info=copy.deepcopy(availability_zone), + methods=methods, + loaded=True) + return availability_zone + + @staticmethod + def create_availability_zones(attrs={}, methods={}, count=2): + """Create multiple fake AZs. + + :param Dictionary attrs: + A dictionary with all attributes + :param Dictionary methods: + A dictionary with all methods + :param int count: + The number of AZs to fake + :return: + A list of FakeResource objects faking the AZs + """ + availability_zones = [] + for i in range(0, count): + availability_zone = \ + FakeAvailabilityZone.create_one_availability_zone( + attrs, methods) + availability_zones.append(availability_zone) + + return availability_zones |
