summaryrefslogtreecommitdiff
path: root/openstackclient/tests/compute
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-02-18 09:03:49 +0000
committerGerrit Code Review <review@openstack.org>2016-02-18 09:03:49 +0000
commit36b21461d9c09883b7c8c07d51204cd98f90d298 (patch)
treec687c6e16289dd32f24e73a13ec57d3e6f78945a /openstackclient/tests/compute
parentbb153b705a14c2fbf9b3a0936f8a7ca4c56895e3 (diff)
parentddc97c6dc5bc36d678515aeb9f7b3f9e85bd70d0 (diff)
downloadpython-openstackclient-36b21461d9c09883b7c8c07d51204cd98f90d298.tar.gz
Merge "Support "network list" command in nova network"
Diffstat (limited to 'openstackclient/tests/compute')
-rw-r--r--openstackclient/tests/compute/v2/fakes.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/openstackclient/tests/compute/v2/fakes.py b/openstackclient/tests/compute/v2/fakes.py
index a1c42b45..26c6eaee 100644
--- a/openstackclient/tests/compute/v2/fakes.py
+++ b/openstackclient/tests/compute/v2/fakes.py
@@ -587,3 +587,61 @@ class FakeFloatingIP(object):
if floating_ips is None:
floating_ips = FakeFloatingIP.create_floating_ips(count)
return mock.MagicMock(side_effect=floating_ips)
+
+
+class FakeNetwork(object):
+ """Fake one or more networks."""
+
+ @staticmethod
+ def create_one_network(attrs={}, methods={}):
+ """Create a fake network.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :param Dictionary methods:
+ A dictionary with all methods
+ :return:
+ A FakeResource object, with id, label, cidr
+ """
+ # Set default attributes.
+ network_attrs = {
+ 'id': 'network-id-' + uuid.uuid4().hex,
+ 'label': 'network-label-' + uuid.uuid4().hex,
+ 'cidr': '10.0.0.0/24',
+ }
+
+ # Overwrite default attributes.
+ network_attrs.update(attrs)
+
+ # Set default methods.
+ network_methods = {
+ 'keys': ['id', 'label', 'cidr'],
+ }
+
+ # Overwrite default methods.
+ network_methods.update(methods)
+
+ network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
+ methods=copy.deepcopy(network_methods),
+ loaded=True)
+
+ return network
+
+ @staticmethod
+ def create_networks(attrs={}, methods={}, count=2):
+ """Create multiple fake networks.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :param Dictionary methods:
+ A dictionary with all methods
+ :param int count:
+ The number of networks to fake
+ :return:
+ A list of FakeResource objects faking the networks
+ """
+ networks = []
+ for i in range(0, count):
+ networks.append(FakeNetwork.create_one_network(attrs, methods))
+
+ return networks