summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorMatthew Sherborne <msherborne@gmail.com>2013-03-07 08:06:21 +1000
committerMatthew Sherborne <msherborne@gmail.com>2013-03-12 09:04:16 +1000
commit782dd69de4c6661eeb889b4e5b3b1b8df9d228b6 (patch)
tree16f399a50a95dfbeb23b33787453632ebb42fc31 /nova/tests
parent4c5fb5657a38c9206bd91c1253b1a2456c1cd37f (diff)
Prepare services index method for use with cells
Move the api.openstack.compute.contrib.services' index method's logic out of the openstack api layer and into the compute api layer. The addition of the availability_zone information is already done by the host api. For this reason it was removed from the openstack api layer. The behaviour of the call remains the same, only the functionality has been moved. This patch makes the functionality automatically work in cells. Work towards: bug #1150499 Change-Id: Ia9489f11608167aed5168ccb3b670f395f7de5f7
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_services.py18
-rw-r--r--nova/tests/integrated/test_api_samples.py2
2 files changed, 14 insertions, 6 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_services.py b/nova/tests/api/openstack/compute/contrib/test_services.py
index d4bf62d19..cb7ce67cb 100644
--- a/nova/tests/api/openstack/compute/contrib/test_services.py
+++ b/nova/tests/api/openstack/compute/contrib/test_services.py
@@ -16,6 +16,7 @@
import datetime
from nova.api.openstack.compute.contrib import services
+from nova import availability_zones
from nova import context
from nova import db
from nova import exception
@@ -76,7 +77,13 @@ class FakeRequestWithHostService(object):
GET = {"host": "host1", "service": "nova-compute"}
-def fake_service_get_all(context):
+def fake_host_api_service_get_all(context, filters=None, set_zones=False):
+ if set_zones or 'availability_zone' in filters:
+ return availability_zones.set_availability_zones(context,
+ fake_services_list)
+
+
+def fake_db_api_service_get_all(context, disabled=None):
return fake_services_list
@@ -112,15 +119,16 @@ class ServicesTest(test.TestCase):
def setUp(self):
super(ServicesTest, self).setUp()
- self.stubs.Set(db, "service_get_all", fake_service_get_all)
+ self.context = context.get_admin_context()
+ self.controller = services.ServiceController()
+
+ self.stubs.Set(self.controller.host_api, "service_get_all",
+ fake_host_api_service_get_all)
self.stubs.Set(timeutils, "utcnow", fake_utcnow)
self.stubs.Set(db, "service_get_by_args",
fake_service_get_by_host_binary)
self.stubs.Set(db, "service_update", fake_service_update)
- self.context = context.get_admin_context()
- self.controller = services.ServiceController()
-
def test_services_list(self):
req = FakeRequest()
res_dict = self.controller.index(req)
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index 9fe2c6566..fe155655b 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -1956,7 +1956,7 @@ class ServicesJsonTest(ApiSampleTestBase):
def setUp(self):
super(ServicesJsonTest, self).setUp()
self.stubs.Set(db, "service_get_all",
- test_services.fake_service_get_all)
+ test_services.fake_db_api_service_get_all)
self.stubs.Set(timeutils, "utcnow", test_services.fake_utcnow)
self.stubs.Set(db, "service_get_by_args",
test_services.fake_service_get_by_host_binary)