diff options
| author | Jenkins <jenkins@review.openstack.org> | 2016-02-04 00:40:09 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2016-02-04 00:40:09 +0000 |
| commit | 48697de28fde6bdf449f6cdc035d9fad56c7c50d (patch) | |
| tree | 122268b0877d6e4e4f8fbbe3e581ad809710952a /openstackclient/tests/network | |
| parent | e4c0d8583dbff3057f144cd6a5c1461ae06dbc67 (diff) | |
| parent | 4d332defbc4231f77b7459d4abda88a36a65d37d (diff) | |
| download | python-openstackclient-48697de28fde6bdf449f6cdc035d9fad56c7c50d.tar.gz | |
Merge "Support listing network availability zones"
Diffstat (limited to 'openstackclient/tests/network')
| -rw-r--r-- | openstackclient/tests/network/v2/fakes.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/openstackclient/tests/network/v2/fakes.py b/openstackclient/tests/network/v2/fakes.py index f07d9d3e..516995eb 100644 --- a/openstackclient/tests/network/v2/fakes.py +++ b/openstackclient/tests/network/v2/fakes.py @@ -69,6 +69,59 @@ class TestNetworkV2(utils.TestCommand): ) +class FakeAvailabilityZone(object): + """Fake one or more network 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 name, state, etc. + """ + # Set default attributes. + availability_zone = { + 'name': uuid.uuid4().hex, + 'state': 'available', + 'resource': 'network', + } + + # 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 + + class FakeNetwork(object): """Fake one or more networks.""" |
