Merge "Fixup uses of mock in hyperv tests"

This commit is contained in:
Jenkins 2015-07-24 06:44:25 +00:00 committed by Gerrit Code Review
commit 2d8b128066
2 changed files with 11 additions and 4 deletions

View File

@ -14,7 +14,6 @@
import mock
from oslo_utils import units
import testtools
from nova import test
from nova.virt.hyperv import constants
@ -243,12 +242,18 @@ class VHDUtilsTestCase(VHDUtilsBaseTestCase):
self.assertEqual(constants.DISK_FORMAT_VHDX, format)
def test_get_vhd_format_vhd(self):
raise testtools.TestCase.skipException("Bug 1473401")
with mock.patch('nova.virt.hyperv.vhdutils.open',
mock.mock_open(read_data=vhdutils.VHD_SIGNATURE),
mock.mock_open(),
create=True) as mock_open:
f = mock_open.return_value
f.tell.return_value = 1024
readdata = ['notthesig', vhdutils.VHD_SIGNATURE]
def read(*args):
for content in readdata:
yield content
f.read.side_effect = read()
format = self._vhdutils.get_vhd_format(self._FAKE_VHD_PATH)

View File

@ -19,6 +19,7 @@ import mock
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_utils import units
import unittest2
from nova import exception
from nova.tests.unit import fake_instance
@ -965,6 +966,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
self._vmops._MAX_CONSOLE_LOG_FILE_SIZE)
fake_iothread.return_value.start.assert_called_once_with()
@unittest2.skip('mock_open in 1.2 read only works once 1475661')
@mock.patch("os.path.exists")
def test_get_console_output(self, fake_path_exists):
mock_instance = fake_instance.fake_instance_obj(self.context)
@ -974,7 +976,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
mock.sentinel.FAKE_PATH, mock.sentinel.FAKE_PATH_ARCHIVED)
with mock.patch('nova.virt.hyperv.vmops.open',
mock.mock_open(read_data=self.FAKE_LOG * 2),
mock.mock_open(read_data=self.FAKE_LOG),
create=True):
instance_log = self._vmops.get_console_output(mock_instance)
# get_vm_console_log_paths returns 2 paths.