From 02130b6f9ab6d3443918ae987b419d3b229b39fa Mon Sep 17 00:00:00 2001 From: Mark Washenberger Date: Wed, 22 Feb 2012 11:55:05 -0500 Subject: Fix WeightedHost WeightedHosts don't have zone attributes. Let me know if I'm missing something and should be adding a hasattr check instead of removing the zone reference. Change-Id: If76f23fa46c965fc9004e35dd10da33e2bbb48dc --- nova/tests/scheduler/test_least_cost.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/scheduler/test_least_cost.py b/nova/tests/scheduler/test_least_cost.py index 6b72b026d..7c09e4e69 100644 --- a/nova/tests/scheduler/test_least_cost.py +++ b/nova/tests/scheduler/test_least_cost.py @@ -16,6 +16,7 @@ Tests For Least Cost functions. """ from nova import context +from nova.scheduler import host_manager from nova.scheduler import least_cost from nova import test from nova.tests.scheduler import fakes @@ -89,3 +90,24 @@ class LeastCostTestCase(test.TestCase): options) self.assertEqual(weighted_host.weight, 10512) self.assertEqual(weighted_host.host_state.host, 'host1') + + +class TestWeightedHost(test.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_dict_conversion_without_host_state(self): + host = least_cost.WeightedHost('someweight') + expected = {'weight': 'someweight'} + self.assertDictMatch(host.to_dict(), expected) + + def test_dict_conversion_with_host_state(self): + host_state = host_manager.HostState('somehost', 'sometopic') + host = least_cost.WeightedHost('someweight', host_state) + expected = {'weight': 'someweight', + 'host': 'somehost'} + self.assertDictMatch(host.to_dict(), expected) -- cgit