summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-07-01 15:07:08 +0000
committerTarmac <>2011-07-01 15:07:08 +0000
commitb69eaefcccc682a270a66ce33b9083ba40a1a71f (patch)
tree7f9c567ab0b28dcadc605cef2d12da20729f3b2a /nova/tests
parent7d544631f0c767727c5a48627617d995f8890ae6 (diff)
parent73a4b0496e1973d3d8af699d0d0d50829ef026c3 (diff)
Fixed the case where an exception was thrown when trying to get a list of flavors via the api yet there were no flavors to list.
hand tested :)
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/test_flavors.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/test_flavors.py b/nova/tests/api/openstack/test_flavors.py
index d1c62e454..fba4d593a 100644
--- a/nova/tests/api/openstack/test_flavors.py
+++ b/nova/tests/api/openstack/test_flavors.py
@@ -87,6 +87,19 @@ class FlavorsTest(test.TestCase):
]
self.assertEqual(flavors, expected)
+ def test_get_empty_flavor_list_v1_0(self):
+ def _return_empty(self):
+ return {}
+ self.stubs.Set(nova.db.api, "instance_type_get_all",
+ _return_empty)
+
+ req = webob.Request.blank('/v1.0/flavors')
+ res = req.get_response(fakes.wsgi_app())
+ self.assertEqual(res.status_int, 200)
+ flavors = json.loads(res.body)["flavors"]
+ expected = []
+ self.assertEqual(flavors, expected)
+
def test_get_flavor_list_detail_v1_0(self):
req = webob.Request.blank('/v1.0/flavors/detail')
res = req.get_response(fakes.wsgi_app())
@@ -261,3 +274,16 @@ class FlavorsTest(test.TestCase):
},
]
self.assertEqual(flavor, expected)
+
+ def test_get_empty_flavor_list_v1_1(self):
+ def _return_empty(self):
+ return {}
+ self.stubs.Set(nova.db.api, "instance_type_get_all",
+ _return_empty)
+
+ req = webob.Request.blank('/v1.1/flavors')
+ res = req.get_response(fakes.wsgi_app())
+ self.assertEqual(res.status_int, 200)
+ flavors = json.loads(res.body)["flavors"]
+ expected = []
+ self.assertEqual(flavors, expected)