From 5a948407ce3673cc3188c23bb243e8d38ee59dd1 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Sun, 31 May 2015 12:41:36 +0530 Subject: [PATCH] Add missing unit test for goodness weigher Add a unit test for goodness weigher to test unset goodness function in host capabilities. Change-Id: I67f86d065f2c740a7beef641250b0881cf63deaa --- .../tests/unit/scheduler/test_goodness_weigher.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cinder/tests/unit/scheduler/test_goodness_weigher.py b/cinder/tests/unit/scheduler/test_goodness_weigher.py index c042d1f71..d0a19a4f1 100644 --- a/cinder/tests/unit/scheduler/test_goodness_weigher.py +++ b/cinder/tests/unit/scheduler/test_goodness_weigher.py @@ -24,6 +24,19 @@ class GoodnessWeigherTestCase(test.TestCase): def setUp(self): super(GoodnessWeigherTestCase, self).setUp() + def test_goodness_weigher_with_no_goodness_function(self): + weigher = goodness.GoodnessWeigher() + host_state = fakes.FakeHostState('host1', { + 'host': 'host.example.com', + 'capabilities': { + 'foo': '50' + } + }) + + weight_properties = {} + weight = weigher._weigh_object(host_state, weight_properties) + self.assertEqual(0, weight) + def test_goodness_weigher_passing_host(self): weigher = goodness.GoodnessWeigher() host_state = fakes.FakeHostState('host1', { -- 2.45.2