diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-01-23 19:33:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-01-23 19:33:11 +0000 |
| commit | 152da40a0651bfbdeb748c249e771c10e716c79c (patch) | |
| tree | 1f6cf4ec149c3c257d2af1b0ea5b10704b69f5d4 /nova/tests | |
| parent | ba5a60bdaf6697ac52d80b40b763da6c75b6efc7 (diff) | |
| parent | a6cae3ce38e763d190e0f9d9680d44c1ecd11711 (diff) | |
Merge "Add context and request spec to filter_properties"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/scheduler/fakes.py | 12 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_distributed_scheduler.py | 19 |
2 files changed, 18 insertions, 13 deletions
diff --git a/nova/tests/scheduler/fakes.py b/nova/tests/scheduler/fakes.py index db50193a9..8abf68e52 100644 --- a/nova/tests/scheduler/fakes.py +++ b/nova/tests/scheduler/fakes.py @@ -16,6 +16,8 @@ Fakes For Scheduler tests. """ +import mox + from nova import db from nova.scheduler import distributed_scheduler from nova.scheduler import host_manager @@ -99,9 +101,9 @@ class FakeComputeAPI(object): pass -def mox_host_manager_db_calls(mox, context): - mox.StubOutWithMock(db, 'compute_node_get_all') - mox.StubOutWithMock(db, 'instance_get_all') +def mox_host_manager_db_calls(mock, context): + mock.StubOutWithMock(db, 'compute_node_get_all') + mock.StubOutWithMock(db, 'instance_get_all') - db.compute_node_get_all(context).AndReturn(COMPUTE_NODES) - db.instance_get_all(context).AndReturn(INSTANCES) + db.compute_node_get_all(mox.IgnoreArg()).AndReturn(COMPUTE_NODES) + db.instance_get_all(mox.IgnoreArg()).AndReturn(INSTANCES) diff --git a/nova/tests/scheduler/test_distributed_scheduler.py b/nova/tests/scheduler/test_distributed_scheduler.py index ca498f7aa..8e586ac8b 100644 --- a/nova/tests/scheduler/test_distributed_scheduler.py +++ b/nova/tests/scheduler/test_distributed_scheduler.py @@ -18,7 +18,6 @@ Tests For Distributed Scheduler. import json -from nova.compute import api as compute_api from nova import context from nova import db from nova import exception @@ -165,32 +164,36 @@ class DistributedSchedulerTestCase(test.TestCase): a non-admin context. DB actions should work.""" self.was_admin = False - def fake_schedule(context, *args, **kwargs): + def fake_get(context, *args, **kwargs): # make sure this is called with admin context, even though # we're using user context below self.was_admin = context.is_admin - return [] + return {} sched = fakes.FakeDistributedScheduler() - self.stubs.Set(sched, '_schedule', fake_schedule) + self.stubs.Set(sched.host_manager, 'get_all_host_states', fake_get) fake_context = context.RequestContext('user', 'project') + request_spec = {'instance_type': {'memory_mb': 1, 'local_gb': 1}, + 'instance_properties': {'project_id': 1}} self.assertRaises(exception.NoValidHost, sched.schedule_run_instance, - fake_context, {}) + fake_context, request_spec) self.assertTrue(self.was_admin) def test_schedule_bad_topic(self): """Parameter checking.""" sched = fakes.FakeDistributedScheduler() - self.assertRaises(NotImplementedError, sched._schedule, None, "foo", - {}) + fake_context = context.RequestContext('user', 'project') + self.assertRaises(NotImplementedError, sched._schedule, fake_context, + "foo", {}) def test_schedule_no_instance_type(self): """Parameter checking.""" sched = fakes.FakeDistributedScheduler() request_spec = {'instance_properties': {}} - self.assertRaises(NotImplementedError, sched._schedule, None, + fake_context = context.RequestContext('user', 'project') + self.assertRaises(NotImplementedError, sched._schedule, fake_context, "compute", request_spec=request_spec) def test_schedule_happy_day(self): |
