Add positive tests for os-floating-ip-pools
List floating ip pools.
Change-Id: Ia7d33a61c7227b72e04f34660fcff4ce916ead79
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py
index e380334..acb1f5c 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -93,6 +93,14 @@
self.assertRaises(exceptions.NotFound,
self.client.get_floating_ip_details, non_exist_id)
+ @attr(type='gate')
+ def test_list_floating_ip_pools(self):
+ # Positive test:Should return the list of floating IP Pools
+ resp, floating_ip_pools = self.client.list_floating_ip_pools()
+ self.assertEqual(200, resp.status)
+ self.assertNotEqual(0, len(floating_ip_pools),
+ "Expected floating IP Pools. Got zero.")
+
class FloatingIPDetailsTestXML(FloatingIPDetailsTestJSON):
_interface = 'xml'
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 27733ac..6963113 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -94,3 +94,13 @@
except exceptions.NotFound:
return True
return False
+
+ def list_floating_ip_pools(self, params=None):
+ """Returns a list of all floating IP Pools."""
+ url = 'os-floating-ip-pools'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['floating_ip_pools']
diff --git a/tempest/services/compute/xml/floating_ips_client.py b/tempest/services/compute/xml/floating_ips_client.py
index 278cc88..2fffaa2 100644
--- a/tempest/services/compute/xml/floating_ips_client.py
+++ b/tempest/services/compute/xml/floating_ips_client.py
@@ -107,3 +107,13 @@
except exceptions.NotFound:
return True
return False
+
+ def list_floating_ip_pools(self, params=None):
+ """Returns a list of all floating IP Pools."""
+ url = 'os-floating-ip-pools'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url, self.headers)
+ body = self._parse_array(etree.fromstring(body))
+ return resp, body