

def test_extend_raw_success(self):
    imgfile = tempfile.NamedTemporaryFile()
    self.addCleanup(imgfile.close)
    imgsize = 10
    image = imgmodel.LocalFileImage(imgfile, imgmodel.FORMAT_RAW)
    self.mox.StubOutWithMock(api, 'can_resize_image')
    self.mox.StubOutWithMock(utils, 'execute')
    self.mox.StubOutWithMock(api, 'resize2fs')
    api.can_resize_image(imgfile, imgsize).AndReturn(True)
    utils.execute('qemu-img', 'resize', imgfile, imgsize)
    utils.execute('e2label', image.path)
    api.resize2fs(imgfile, run_as_root=False, check_exit_code=[0])
    self.mox.ReplayAll()
    api.extend(image, imgsize)

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/virt/disk/test_api.py APITestCase.test_extend_raw_success/original