Merge "Remove mox in unit/api/openstack/compute/test_hosts.py"

This commit is contained in:
Zuul 2018-04-25 00:35:49 +00:00 committed by Gerrit Code Review
commit 82effe8d37

View File

@ -40,7 +40,7 @@ def stub_service_get_by_host_and_binary(context, host_name, binary):
return service return service
def stub_set_host_enabled(context, host_name, enabled): def stub_set_host_enabled(self, context, host_name, enabled):
"""Simulates three possible behaviours for VM drivers or compute """Simulates three possible behaviours for VM drivers or compute
drivers when enabling or disabling a host. drivers when enabling or disabling a host.
@ -65,7 +65,7 @@ def stub_set_host_enabled(context, host_name, enabled):
return results[enabled] return results[enabled]
def stub_set_host_maintenance(context, host_name, mode): def stub_set_host_maintenance(self, context, host_name, mode):
# We'll simulate success and failure by assuming # We'll simulate success and failure by assuming
# that 'host_c1' always succeeds, and 'host_c2' # that 'host_c1' always succeeds, and 'host_c2'
# always fails # always fails
@ -87,7 +87,7 @@ def stub_set_host_maintenance(context, host_name, mode):
return results[mode] return results[mode]
def stub_host_power_action(context, host_name, action): def stub_host_power_action(self, context, host_name, action):
if host_name == "notimplemented": if host_name == "notimplemented":
raise NotImplementedError() raise NotImplementedError()
elif host_name == "dummydest": elif host_name == "dummydest":
@ -142,13 +142,13 @@ class HostTestCaseV21(test.TestCase):
self.stub_out('nova.db.service_get_by_host_and_binary', self.stub_out('nova.db.service_get_by_host_and_binary',
stub_service_get_by_host_and_binary) stub_service_get_by_host_and_binary)
# 'host_c1' always succeeds, and 'host_c2' # 'host_c1' always succeeds, and 'host_c2'
self.stubs.Set(self.hosts_api, 'set_host_enabled', self.stub_out('nova.compute.api.HostAPI.set_host_enabled',
stub_set_host_enabled) stub_set_host_enabled)
# 'host_c1' always succeeds, and 'host_c2' # 'host_c1' always succeeds, and 'host_c2'
self.stubs.Set(self.hosts_api, 'set_host_maintenance', self.stub_out('nova.compute.api.HostAPI.set_host_maintenance',
stub_set_host_maintenance) stub_set_host_maintenance)
self.stubs.Set(self.hosts_api, 'host_power_action', self.stub_out('nova.compute.api.HostAPI.host_power_action',
stub_host_power_action) stub_host_power_action)
def setUp(self): def setUp(self):
super(HostTestCaseV21, self).setUp() super(HostTestCaseV21, self).setUp()