qubes/tests: moar fixes

This commit is contained in:
Wojtek Porczyk 2017-09-21 14:18:35 +02:00
parent 40e2c0eec5
commit 589d567ebc
2 changed files with 112 additions and 78 deletions

View File

@ -90,6 +90,11 @@ class AdminAPITestCase(qubes.tests.QubesTestCase):
self.base_dir_patch.stop()
if os.path.exists(self.test_base_dir):
shutil.rmtree(self.test_base_dir)
del self.vm
del self.template
self.app.close()
del self.app
del self.emitter
super(AdminAPITestCase, self).tearDown()
def call_mgmt_func(self, method, dest, arg=b'', payload=b''):
@ -1595,6 +1600,12 @@ class TC_00_VMs(AdminAPITestCase):
self.vm2.volumes['private'].import_volume.return_value = \
self.vm2.volumes['private']
self.addCleanup(self.cleanup_for_clone)
def cleanup_for_clone(self):
del self.vm2
del self.pool
def test_520_vm_volume_clone(self):
self.setup_for_clone()
token = self.call_mgmt_func(b'admin.vm.volume.CloneFrom',

View File

@ -90,9 +90,14 @@ class TC_01_Properties(qubes.tests.SystemTestCase):
template=self.app.default_template,
label='red')
self.loop.run_until_complete(self.vm.create_on_disk())
self.addCleanup(self.cleanup_props)
def cleanup_props(self):
del self.vm
@unittest.expectedFailure
def test_030_clone(self):
try:
testvm1 = self.app.add_new_vm(
qubes.vm.appvm.AppVM,
name=self.make_vm_name("vm"),
@ -177,6 +182,19 @@ class TC_01_Properties(qubes.tests.SystemTestCase):
self.assertEqual(testvm1.features, testvm3.features)
self.assertEqual(testvm1.firewall.rules,
testvm2.firewall.rules)
finally:
try:
del testvm1
except NameError:
pass
try:
del testvm2
except NameError:
pass
try:
del testvm3
except NameError:
pass
def test_020_name_conflict_app(self):
# TODO decide what exception should be here
@ -322,12 +340,16 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase):
super(TC_03_QvmRevertTemplateChanges, self).setUp()
self.init_default_template()
def cleanup_template(self):
del self.test_template
def setup_pv_template(self):
self.test_template = self.app.add_new_vm(
qubes.vm.templatevm.TemplateVM,
name=self.make_vm_name("pv-clone"),
label='red'
)
self.addCleanup(self.cleanup_template)
self.test_template.clone_properties(self.app.default_template)
self.loop.run_until_complete(
self.test_template.clone_disk_files(self.app.default_template))
@ -340,6 +362,7 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase):
label='red',
virt_mode='hvm',
)
self.addCleanup(self.cleanup_template)
self.loop.run_until_complete(self.test_template.create_on_disk())
self.app.save()