tests: port backupcompatibility to core3 API

This commit is contained in:
Marek Marczykowski-Górecki 2016-03-16 01:01:58 +01:00 committed by Wojtek Porczyk
parent 8c5d42a095
commit c55ca8004a
3 changed files with 49 additions and 42 deletions

View File

@ -822,7 +822,7 @@ def load_tests(loader, tests, pattern): # pylint: disable=unused-argument
'qubes.tests.int.network', 'qubes.tests.int.network',
# 'qubes.tests.vm_qrexec_gui', # 'qubes.tests.vm_qrexec_gui',
'qubes.tests.int.backup', 'qubes.tests.int.backup',
# 'qubes.tests.backupcompatibility', 'qubes.tests.int.backupcompatibility',
# 'qubes.tests.regressions', # 'qubes.tests.regressions',
# tool tests # tool tests

View File

@ -29,8 +29,6 @@ import subprocess
import unittest import unittest
import sys import sys
import re import re
from qubes.qubes import QubesVmCollection, QubesException
from qubes import backup
import qubes.tests import qubes.tests
@ -146,6 +144,11 @@ compression-filter=gzip
''' '''
class TC_00_BackupCompatibility(qubes.tests.BackupTestsMixin, qubes.tests.QubesTestCase): class TC_00_BackupCompatibility(qubes.tests.BackupTestsMixin, qubes.tests.QubesTestCase):
def tearDown(self):
self.remove_test_vms(prefix="test-")
super(TC_00_BackupCompatibility, self).tearDown()
def create_whitelisted_appmenus(self, filename): def create_whitelisted_appmenus(self, filename):
f = open(filename, "w") f = open(filename, "w")
f.write("gnome-terminal.desktop\n") f.write("gnome-terminal.desktop\n")
@ -401,19 +404,22 @@ class TC_00_BackupCompatibility(qubes.tests.BackupTestsMixin, qubes.tests.QubesT
f.write(QUBESXML_R1) f.write(QUBESXML_R1)
f.close() f.close()
self.restore_backup(self.backupdir, options={ self.restore_backup(self.backupdir,
'use-default-template': True, options={
'use-default-netvm': True, 'use-default-template': True,
}) 'use-default-netvm': True,
self.assertIsNotNone(self.qc.get_vm_by_name("test-template-clone")) },
self.assertIsNotNone(self.qc.get_vm_by_name("test-testproxy")) expect_errors=['Kernel None not installed, using default one']
self.assertIsNotNone(self.qc.get_vm_by_name("test-work")) )
self.assertIsNotNone(self.qc.get_vm_by_name("test-standalonevm")) with self.assertNotRaises(KeyError):
self.assertIsNotNone(self.qc.get_vm_by_name( vm = self.app.domains["test-template-clone"]
"test-custom-template-appvm")) vm = self.app.domains["test-testproxy"]
self.assertEqual(self.qc.get_vm_by_name("test-custom-template-appvm") vm = self.app.domains["test-work"]
vm = self.app.domains["test-standalonevm"]
vm = self.app.domains["test-custom-template-appvm"]
self.assertEqual(self.app.domains["test-custom-template-appvm"]
.template, .template,
self.qc.get_vm_by_name("test-template-clone")) self.app.domains["test-template-clone"])
def test_200_r2b2(self): def test_200_r2b2(self):
self.create_v1_files(r2b2=True) self.create_v1_files(r2b2=True)
@ -425,16 +431,16 @@ class TC_00_BackupCompatibility(qubes.tests.BackupTestsMixin, qubes.tests.QubesT
self.restore_backup(self.backupdir, options={ self.restore_backup(self.backupdir, options={
'use-default-template': True, 'use-default-template': True,
}) })
self.assertIsNotNone(self.qc.get_vm_by_name("test-template-clone")) with self.assertNotRaises(KeyError):
self.assertIsNotNone(self.qc.get_vm_by_name("test-testproxy")) vm = self.app.domains["test-template-clone"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-work")) vm = self.app.domains["test-testproxy"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-testhvm")) vm = self.app.domains["test-work"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-standalonevm")) vm = self.app.domains["test-testhvm"]
self.assertIsNotNone(self.qc.get_vm_by_name( vm = self.app.domains["test-standalonevm"]
"test-custom-template-appvm")) vm = self.app.domains["test-custom-template-appvm"]
self.assertEqual(self.qc.get_vm_by_name("test-custom-template-appvm") self.assertEqual(self.app.domains["test-custom-template-appvm"]
.template, .template,
self.qc.get_vm_by_name("test-template-clone")) self.app.domains["test-template-clone"])
def test_210_r2(self): def test_210_r2(self):
self.create_v3_backup(False) self.create_v3_backup(False)
@ -443,16 +449,16 @@ class TC_00_BackupCompatibility(qubes.tests.BackupTestsMixin, qubes.tests.QubesT
'use-default-template': True, 'use-default-template': True,
'use-default-netvm': True, 'use-default-netvm': True,
}) })
self.assertIsNotNone(self.qc.get_vm_by_name("test-template-clone")) with self.assertNotRaises(KeyError):
self.assertIsNotNone(self.qc.get_vm_by_name("test-testproxy")) vm = self.app.domains["test-template-clone"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-work")) vm = self.app.domains["test-testproxy"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-testhvm")) vm = self.app.domains["test-work"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-standalonevm")) vm = self.app.domains["test-testhvm"]
self.assertIsNotNone(self.qc.get_vm_by_name( vm = self.app.domains["test-standalonevm"]
"test-custom-template-appvm")) vm = self.app.domains["test-custom-template-appvm"]
self.assertEqual(self.qc.get_vm_by_name("test-custom-template-appvm") self.assertEqual(self.app.domains["test-custom-template-appvm"]
.template, .template,
self.qc.get_vm_by_name("test-template-clone")) self.app.domains["test-template-clone"])
def test_220_r2_encrypted(self): def test_220_r2_encrypted(self):
self.create_v3_backup(True) self.create_v3_backup(True)
@ -461,13 +467,13 @@ class TC_00_BackupCompatibility(qubes.tests.BackupTestsMixin, qubes.tests.QubesT
'use-default-template': True, 'use-default-template': True,
'use-default-netvm': True, 'use-default-netvm': True,
}) })
self.assertIsNotNone(self.qc.get_vm_by_name("test-template-clone")) with self.assertNotRaises(KeyError):
self.assertIsNotNone(self.qc.get_vm_by_name("test-testproxy")) vm = self.app.domains["test-template-clone"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-work")) vm = self.app.domains["test-testproxy"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-testhvm")) vm = self.app.domains["test-work"]
self.assertIsNotNone(self.qc.get_vm_by_name("test-standalonevm")) vm = self.app.domains["test-testhvm"]
self.assertIsNotNone(self.qc.get_vm_by_name( vm = self.app.domains["test-standalonevm"]
"test-custom-template-appvm")) vm = self.app.domains["test-custom-template-appvm"]
self.assertEqual(self.qc.get_vm_by_name("test-custom-template-appvm") self.assertEqual(self.app.domains["test-custom-template-appvm"]
.template, .template,
self.qc.get_vm_by_name("test-template-clone")) self.app.domains["test-template-clone"])

View File

@ -275,6 +275,7 @@ fi
%dir %{python_sitelib}/qubes/tests/int %dir %{python_sitelib}/qubes/tests/int
%{python_sitelib}/qubes/tests/int/__init__.py* %{python_sitelib}/qubes/tests/int/__init__.py*
%{python_sitelib}/qubes/tests/int/backup.py* %{python_sitelib}/qubes/tests/int/backup.py*
%{python_sitelib}/qubes/tests/int/backupcompatibility.py*
%{python_sitelib}/qubes/tests/int/basic.py* %{python_sitelib}/qubes/tests/int/basic.py*
%{python_sitelib}/qubes/tests/int/dom0_update.py* %{python_sitelib}/qubes/tests/int/dom0_update.py*
%{python_sitelib}/qubes/tests/int/network.py* %{python_sitelib}/qubes/tests/int/network.py*