summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/network/v2/fakes.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-02-22 18:40:37 +0000
committerGerrit Code Review <review@openstack.org>2017-02-22 18:40:37 +0000
commit3746fd2caf1dd3853a4def5f8f5f228bb1b1871a (patch)
tree88c81051a15cc466308f0fb44975b575ec522d7e /openstackclient/tests/unit/network/v2/fakes.py
parentc828216e2b02a9fcee3bb9a10fde2ec5ccd59026 (diff)
parentedaeece7f144545bff9a7b00fccd2ec598ee2144 (diff)
downloadpython-openstackclient-3746fd2caf1dd3853a4def5f8f5f228bb1b1871a.tar.gz
Merge "OSC Network Flavor"
Diffstat (limited to 'openstackclient/tests/unit/network/v2/fakes.py')
-rw-r--r--openstackclient/tests/unit/network/v2/fakes.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py
index dcecbeee..6a73b7e9 100644
--- a/openstackclient/tests/unit/network/v2/fakes.py
+++ b/openstackclient/tests/unit/network/v2/fakes.py
@@ -390,6 +390,69 @@ class FakeNetwork(object):
return mock.Mock(side_effect=networks)
+class FakeNetworkFlavor(object):
+ """Fake Network Flavor."""
+
+ @staticmethod
+ def create_one_network_flavor(attrs=None):
+ """Create a fake network flavor.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :return:
+ A FakeResource object faking the network flavor
+ """
+ attrs = attrs or {}
+
+ fake_uuid = uuid.uuid4().hex
+ network_flavor_attrs = {
+ 'description': 'network-flavor-description-' + fake_uuid,
+ 'enabled': True,
+ 'id': 'network-flavor-id-' + fake_uuid,
+ 'name': 'network-flavor-name-' + fake_uuid,
+ 'service_type': 'vpn',
+ 'tenant_id': 'project-id-' + uuid.uuid4().hex,
+ }
+
+ # Overwrite default attributes.
+ network_flavor_attrs.update(attrs)
+
+ network_flavor = fakes.FakeResource(
+ info=copy.deepcopy(network_flavor_attrs),
+ loaded=True
+ )
+
+ network_flavor.project_id = network_flavor_attrs['tenant_id']
+ network_flavor.is_enabled = network_flavor_attrs['enabled']
+
+ return network_flavor
+
+ @staticmethod
+ def create_flavor(attrs=None, count=2):
+ """Create multiple fake network flavors.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :param int count:
+ The number of network flavors to fake
+ :return:
+ A list of FakeResource objects faking the network falvors
+ """
+ network_flavors = []
+ for i in range(0, count):
+ network_flavors.append(
+ FakeNetworkFlavor.create_one_network_flavor(attrs)
+ )
+ return network_flavors
+
+ @staticmethod
+ def get_flavor(network_flavors=None, count=2):
+ """Get a list of flavors."""
+ if network_flavors is None:
+ network_flavors = (FakeNetworkFlavor.create_flavor(count))
+ return mock.Mock(side_effect=network_flavors)
+
+
class FakeNetworkSegment(object):
"""Fake one or more network segments."""