From 3985c1e699d4598f6b95549a20f3b3a941a38bab Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Tue, 16 Apr 2013 14:35:48 -0500 Subject: hypervisor tests more accurate db The hypervisor tests don't accurately model the db because the sqlalchemy DB API requires admin for the compute_node_get_all function. This change makes it so that the fake compute_node_get_all function in the hypervisor test module requires admin just like the sqlalchemy DB function. Change-Id: I5acd45cfbd10ec06d8c5a9425e9c6ed18cff669e --- nova/tests/api/openstack/compute/contrib/test_hypervisors.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/tests/api/openstack/compute/contrib/test_hypervisors.py b/nova/tests/api/openstack/compute/contrib/test_hypervisors.py index e323dce6a..7fc7f9ba2 100644 --- a/nova/tests/api/openstack/compute/contrib/test_hypervisors.py +++ b/nova/tests/api/openstack/compute/contrib/test_hypervisors.py @@ -19,6 +19,7 @@ from webob import exc from nova.api.openstack.compute.contrib import hypervisors from nova import context from nova import db +from nova.db.sqlalchemy import api as db_api from nova import exception from nova import test from nova.tests.api.openstack import fakes @@ -79,6 +80,7 @@ TEST_SERVERS = [dict(name="inst1", uuid="uuid1", host="compute1"), dict(name="inst4", uuid="uuid4", host="compute2")] +@db_api.require_admin_context def fake_compute_node_get_all(context): return TEST_HYPERS @@ -185,7 +187,8 @@ class HypervisorsTest(test.TestCase): dict(name="inst4", uuid="uuid4")])) def test_index(self): - req = fakes.HTTPRequest.blank('/v2/fake/os-hypervisors') + req = fakes.HTTPRequest.blank('/v2/fake/os-hypervisors', + use_admin_context=True) result = self.controller.index(req) self.assertEqual(result, dict(hypervisors=[ @@ -193,7 +196,8 @@ class HypervisorsTest(test.TestCase): dict(id=2, hypervisor_hostname="hyper2")])) def test_detail(self): - req = fakes.HTTPRequest.blank('/v2/fake/os-hypervisors/detail') + req = fakes.HTTPRequest.blank('/v2/fake/os-hypervisors/detail', + use_admin_context=True) result = self.controller.detail(req) self.assertEqual(result, dict(hypervisors=[ -- cgit