tests: extend TestPool storage driver to make create_on_disk working

Add dummy TestVolume with empty create() method. Other core code
requires also TestPool.get_volume implemented, so add that too (naive
version remembering instances returned from TestPool.init_volume).
This commit is contained in:
Marek Marczykowski-Górecki 2020-07-05 18:22:46 +02:00
parent d9d55b0586
commit 410a0728cc
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -51,11 +51,24 @@ class TestVM(object):
def is_running(self): def is_running(self):
return self.running return self.running
class TestVolume(qubes.storage.Volume):
def create(self):
pass
class TestPool(qubes.storage.Pool): class TestPool(qubes.storage.Pool):
def __init__(self, *args, **kwargs):
super(TestPool, self).__init__(*args, **kwargs)
self._volumes = {}
def init_volume(self, vm, volume_config): def init_volume(self, vm, volume_config):
vid = '{}/{}'.format(vm.name, volume_config['name']) vid = '{}/{}'.format(vm.name, volume_config['name'])
assert volume_config.pop('pool', None) == self assert volume_config.pop('pool', None) == self
return qubes.storage.Volume(vid=vid, pool=self, **volume_config) vol = TestVolume(vid=vid, pool=self, **volume_config)
self._volumes[vid] = vol
return vol
def get_volume(self, vid):
return self._volumes[vid]
class TC_90_AppVM(qubes.tests.vm.qubesvm.QubesVMTestsMixin, class TC_90_AppVM(qubes.tests.vm.qubesvm.QubesVMTestsMixin,