

@mock.patch('see.context.resources.qemu.libvirt')
@mock.patch('see.context.resources.qemu.domain_create')
@mock.patch('see.context.resources.network.delete')
@mock.patch('see.context.resources.qemu.pool_delete')
@mock.patch('see.context.resources.qemu.domain_delete')
def test_cleanup(self, delete_mock, pool_delete_mock, network_delete_mock, create_mock, libvirt_mock):
    'Resources are released on cleanup.'
    resources = qemu.QEMUResources('foo', {
        'domain': 'bar',
        'disk': {
            'image': '/foo/bar',
        },
    })
    resources._domain = mock.Mock()
    resources._network = mock.Mock()
    libvirt_mock._hypervisor = mock.Mock()
    resources._storage_pool = mock.Mock()
    resources.cleanup()
    delete_mock.assert_called_with(resources.domain, mock.ANY)
    pool_delete_mock.assert_called_with(resources.storage_pool, mock.ANY)
    network_delete_mock.assert_called_with(resources.network)
    self.assertTrue(resources._hypervisor.close.called)

dataset/ETHPy150Open F-Secure/see/see/context/resources/test/qemu_test.py ResourcesTest.test_cleanup/VarMisuse@112/214 `resources`->`libvirt_mock`