tests: make storage.TC_00_Pool usable outside of dom0

This commit is contained in:
Marek Marczykowski-Górecki 2019-02-19 00:54:17 +01:00
parent 2bd709501b
commit 5aa49168e5
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, see <https://www.gnu.org/licenses/>. # License along with this library; if not, see <https://www.gnu.org/licenses/>.
# #
import shutil
import unittest.mock import unittest.mock
import qubes.log import qubes.log
import qubes.storage import qubes.storage
@ -23,7 +24,7 @@ from qubes.exc import QubesException
from qubes.storage import pool_drivers from qubes.storage import pool_drivers
from qubes.storage.file import FilePool from qubes.storage.file import FilePool
from qubes.storage.reflink import ReflinkPool from qubes.storage.reflink import ReflinkPool
from qubes.tests import SystemTestCase from qubes.tests import SystemTestCase, QubesTestCase
# :pylint: disable=invalid-name # :pylint: disable=invalid-name
@ -86,15 +87,25 @@ class TestApp(qubes.Qubes):
super(TestApp, self).__init__('/tmp/qubes-test.xml', super(TestApp, self).__init__('/tmp/qubes-test.xml',
load=False, offline_mode=True, **kwargs) load=False, offline_mode=True, **kwargs)
self.load_initial_values() self.load_initial_values()
self.default_pool = self.pools['varlibqubes']
class TC_00_Pool(SystemTestCase): class TC_00_Pool(QubesTestCase):
""" This class tests the utility methods from :mod:``qubes.storage`` """ """ This class tests the utility methods from :mod:``qubes.storage`` """
def setUp(self): def setUp(self):
super(TC_00_Pool, self).setUp() super(TC_00_Pool, self).setUp()
self.app.close() self.basedir_patch = unittest.mock.patch('qubes.config.qubes_base_dir',
'/tmp/qubes-test-basedir')
self.basedir_patch.start()
self.app = TestApp() self.app = TestApp()
def tearDown(self):
self.basedir_patch.stop()
self.app.close()
del self.app
shutil.rmtree('/tmp/qubes-test-basedir', ignore_errors=True)
super().tearDown()
def test_000_unknown_pool_driver(self): def test_000_unknown_pool_driver(self):
# :pylint: disable=protected-access # :pylint: disable=protected-access
""" Expect an exception when unknown pool is requested""" """ Expect an exception when unknown pool is requested"""