summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorPhilip Knouff <philip.knouff@mailtrust.com>2012-01-23 15:03:00 -0500
committerPhilip Knouff <philip.knouff@mailtrust.com>2012-01-23 17:09:24 -0500
commit48f4e140ec929d8abec6145088df9db758ecda9a (patch)
tree91c3cd797a6ad98055bd792bd2cc972ef5f0ebe9 /nova/tests
parent61758c4acb132ceb9f25c08db531e0360f44ff6a (diff)
Fixed limiting for flavors
Fixes bug #912922 Change-Id: Iea5a070b83e35fe19480e1bd4ee96f2a67a7c0d3
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/compute/test_flavors.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/compute/test_flavors.py b/nova/tests/api/openstack/compute/test_flavors.py
index 37b67fc32..672f5b8eb 100644
--- a/nova/tests/api/openstack/compute/test_flavors.py
+++ b/nova/tests/api/openstack/compute/test_flavors.py
@@ -18,11 +18,14 @@
from lxml import etree
import webob
+import urlparse
+
from nova.api.openstack.compute import flavors
from nova.api.openstack import xmlutil
import nova.compute.instance_types
from nova import exception
from nova import test
+from nova import utils
from nova.tests.api.openstack import fakes
@@ -164,6 +167,84 @@ class FlavorsTest(test.TestCase):
}
self.assertEqual(flavor, expected)
+ def test_get_flavor_detail_with_limit(self):
+ req = fakes.HTTPRequest.blank('/v2/fake/flavors/detail?limit=1')
+ response = self.controller.index(req)
+ response_list = response["flavors"]
+ response_links = response["flavors_links"]
+
+ alternate = "%s/fake/flavors/%s"
+
+ expected_flavors = [
+ {
+ "id": "1",
+ "name": "flavor 1",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://localhost/v2/fake/flavors/1",
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://localhost/fake/flavors/1",
+ },
+ ],
+ },
+ ]
+ self.assertEqual(response_list, expected_flavors)
+ self.assertEqual(response_links[0]['rel'], 'next')
+
+ href_parts = urlparse.urlparse(response_links[0]['href'])
+ self.assertEqual('/v2/fake/flavors', href_parts.path)
+ params = urlparse.parse_qs(href_parts.query)
+ self.assertDictMatch({'limit': ['1'], 'marker': ['1']}, params)
+
+ def test_get_flavor_with_limit(self):
+ req = fakes.HTTPRequest.blank('/v2/fake/flavors?limit=2')
+ response = self.controller.index(req)
+ response_list = response["flavors"]
+ response_links = response["flavors_links"]
+
+ alternate = "%s/fake/flavors/%s"
+
+ expected_flavors = [
+ {
+ "id": "1",
+ "name": "flavor 1",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://localhost/v2/fake/flavors/1",
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://localhost/fake/flavors/1",
+ },
+ ],
+ },
+ {
+ "id": "2",
+ "name": "flavor 2",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://localhost/v2/fake/flavors/2",
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://localhost/fake/flavors/2",
+ },
+ ],
+ }
+ ]
+ self.assertEqual(response_list, expected_flavors)
+ self.assertEqual(response_links[0]['rel'], 'next')
+
+ href_parts = urlparse.urlparse(response_links[0]['href'])
+ self.assertEqual('/v2/fake/flavors', href_parts.path)
+ params = urlparse.parse_qs(href_parts.query)
+ self.assertDictMatch({'limit': ['2'], 'marker': ['2']}, params)
+
def test_get_flavor_list_detail(self):
req = fakes.HTTPRequest.blank('/v2/fake/flavors/detail')
flavor = self.controller.detail(req)
@@ -222,6 +303,7 @@ class FlavorsTest(test.TestCase):
def test_get_flavor_list_filter_min_ram(self):
"""Flavor lists may be filtered by minRam"""
+ self.maxDiff = None
req = fakes.HTTPRequest.blank('/v2/fake/flavors?minRam=512')
flavor = self.controller.index(req)
expected = {