summaryrefslogtreecommitdiff
path: root/openstackclient/tests/network/v2/fakes.py
diff options
context:
space:
mode:
authorTang Chen <chen.tang@easystack.cn>2016-02-12 13:31:15 +0800
committerTang Chen <chen.tang@easystack.cn>2016-02-18 08:53:39 +0800
commit79fd6d3f2075ecdfdac8c856be135b3fd1260eb5 (patch)
treeb85dcbf94ffe1d8e5cac137ef534d2425c9888c5 /openstackclient/tests/network/v2/fakes.py
parent272ac55776dcc945cdad3d6d38e3356e0c099e45 (diff)
downloadpython-openstackclient-79fd6d3f2075ecdfdac8c856be135b3fd1260eb5.tar.gz
Subnet Pool: Add "subnet pool delete" command
Change-Id: Ic5ba5effcaea2410421a81da8ffce7c0295179e7 Closes-Bug: 1544587 Partially implements: blueprint neutron-client
Diffstat (limited to 'openstackclient/tests/network/v2/fakes.py')
-rw-r--r--openstackclient/tests/network/v2/fakes.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/openstackclient/tests/network/v2/fakes.py b/openstackclient/tests/network/v2/fakes.py
index 77720ee0..aa04b1c0 100644
--- a/openstackclient/tests/network/v2/fakes.py
+++ b/openstackclient/tests/network/v2/fakes.py
@@ -631,3 +631,64 @@ class FakeFloatingIP(object):
if floating_ips is None:
floating_ips = FakeFloatingIP.create_floating_ips(count)
return mock.MagicMock(side_effect=floating_ips)
+
+
+class FakeSubnetPool(object):
+ """Fake one or more subnet pools."""
+
+ @staticmethod
+ def create_one_subnet_pool(attrs={}, methods={}):
+ """Create a fake subnet pool.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :param Dictionary methods:
+ A dictionary with all methods
+ :return:
+ A FakeResource object faking the subnet pool
+ """
+ # Set default attributes.
+ subnet_pool_attrs = {
+ 'id': 'subnet-pool-id-' + uuid.uuid4().hex,
+ 'name': 'subnet-pool-name-' + uuid.uuid4().hex,
+ }
+
+ # Overwrite default attributes.
+ subnet_pool_attrs.update(attrs)
+
+ # Set default methods.
+ subnet_pool_methods = {
+ 'keys': ['id', 'name']
+ }
+
+ # Overwrite default methods.
+ subnet_pool_methods.update(methods)
+
+ subnet_pool = fakes.FakeResource(
+ info=copy.deepcopy(subnet_pool_attrs),
+ methods=copy.deepcopy(subnet_pool_methods),
+ loaded=True
+ )
+
+ return subnet_pool
+
+ @staticmethod
+ def create_subnet_pools(attrs={}, methods={}, count=2):
+ """Create multiple fake subnet pools.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :param Dictionary methods:
+ A dictionary with all methods
+ :param int count:
+ The number of subnet pools to fake
+ :return:
+ A list of FakeResource objects faking the subnet pools
+ """
+ subnet_pools = []
+ for i in range(0, count):
+ subnet_pools.append(
+ FakeSubnetPool.create_one_subnet_pool(attrs, methods)
+ )
+
+ return subnet_pools