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

Replace stubs.Set with mock in
nova/tests/unit/api/openstack/compute/test_hosts.py.

Change-Id: Id0e4c76bdda6a518429c50b5ce12354a315ed9dd
Implements: blueprint mox-removal
This commit is contained in:
Takashi NATSUME 2018-04-06 14:19:10 +09:00
parent 324899c621
commit 33f6ff204a

View File

@ -40,7 +40,7 @@ def stub_service_get_by_host_and_binary(context, host_name, binary):
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
drivers when enabling or disabling a host.
@ -65,7 +65,7 @@ def stub_set_host_enabled(context, host_name, 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
# that 'host_c1' always succeeds, and 'host_c2'
# always fails
@ -87,7 +87,7 @@ def stub_set_host_maintenance(context, host_name, 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":
raise NotImplementedError()
elif host_name == "dummydest":
@ -142,13 +142,13 @@ class HostTestCaseV21(test.TestCase):
self.stub_out('nova.db.service_get_by_host_and_binary',
stub_service_get_by_host_and_binary)
# 'host_c1' always succeeds, and 'host_c2'
self.stubs.Set(self.hosts_api, 'set_host_enabled',
stub_set_host_enabled)
self.stub_out('nova.compute.api.HostAPI.set_host_enabled',
stub_set_host_enabled)
# 'host_c1' always succeeds, and 'host_c2'
self.stubs.Set(self.hosts_api, 'set_host_maintenance',
stub_set_host_maintenance)
self.stubs.Set(self.hosts_api, 'host_power_action',
stub_host_power_action)
self.stub_out('nova.compute.api.HostAPI.set_host_maintenance',
stub_set_host_maintenance)
self.stub_out('nova.compute.api.HostAPI.host_power_action',
stub_host_power_action)
def setUp(self):
super(HostTestCaseV21, self).setUp()