Source code for

# -*- encoding: utf8 -*-
# The Qubes OS Project,
# Copyright (C) 2017 Marek Marczykowski-Górecki
#                               <>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <>.

import qubesadmin.tests

[docs] class TC_00_qvm_pool(qubesadmin.tests.QubesTestCase):
[docs] def test_000_list(self):[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00pool-file\npool-lvm\n'[ ('dom0', 'admin.pool.Info', 'pool-file', None)] = \ b'0\x00driver=file\ndir_path=/var/lib/qubes\n'[ ('dom0', 'admin.pool.Info', 'pool-lvm', None)] = \ b'0\x00driver=lvm\nvolume_group=qubes_dom0\nthin_pool=pool00\n' with as stdout: self.assertEqual(0,['list'], self.assertEqual(stdout.getvalue(), 'NAME DRIVER\n' 'pool-file file\n' 'pool-lvm lvm\n') self.assertAllCalled()
[docs] def test_010_drivers(self):[ ('dom0', 'admin.pool.ListDrivers', None, None)] = \ b'0\x00file dir_path revisions_to_keep\n' \ b'lvm volume_group thin_pool revisions_to_keep\n' with as stdout: self.assertEqual(0,['drivers'], self.assertEqual(stdout.getvalue(), 'DRIVER OPTIONS\n' 'file dir_path, revisions_to_keep\n' 'lvm volume_group, thin_pool, revisions_to_keep\n' ) self.assertAllCalled()
[docs] def test_020_add(self):[ ('dom0', 'admin.pool.Add', 'file', b'name=test-pool\ndir_path=/some/path\n')] = b'0\x00' self.assertEqual(0, ['add', 'test-pool', 'file', '-o', 'dir_path=/some/path'], self.assertAllCalled()
[docs] def test_021_add_multiple(self):[ ('dom0', 'admin.pool.Add', 'file', b'name=test-pool\ndir_path=/some/path\nrw=True\n')] = b'0\x00' self.assertEqual(0, ['add', 'test-pool', 'file', '-o', 'dir_path=/some/path', '-o', 'rw=True'], self.assertAllCalled()
[docs] def test_030_remove(self):[ ('dom0', 'admin.pool.Remove', 'test-pool', None)] = b'0\x00' self.assertEqual(0,['remove', 'test-pool'], self.assertAllCalled()
[docs] def test_031_remove_multiple(self):[ ('dom0', 'admin.pool.Remove', 'test-pool-1', None)] = b'0\x00'[ ('dom0', 'admin.pool.Remove', 'test-pool-2', None)] = b'0\x00' self.assertEqual(0, ['remove', 'test-pool-1', 'test-pool-2'], self.assertAllCalled()
[docs] def test_040_info(self):[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00pool-file\npool-lvm\n'[ ('dom0', 'admin.pool.Info', 'pool-lvm', None)] = \ b'0\x00driver=lvm\nvolume_group=qubes_dom0\nthin_pool=pool00\n' with as stdout: self.assertEqual(0,['info', 'pool-lvm'], self.assertEqual(stdout.getvalue(), 'name pool-lvm\n' 'driver lvm\n' 'thin_pool pool00\n' 'volume_group qubes_dom0\n' ) self.assertAllCalled()
[docs] def test_050_set(self):[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00pool-file\npool-lvm\n'[ ('dom0', 'admin.pool.Set.revisions_to_keep', 'pool-lvm', b'2')] = \ b'0\x00'[( 'dom0', 'admin.pool.Set.ephemeral_volatile', 'pool-lvm', b'True', )] = b'0\x00' self.assertEqual(0,['set', 'pool-lvm', '-o', 'revisions_to_keep=2'], self.assertEqual(0,['set', 'pool-lvm', '-o', 'ephemeral_volatile=True'], self.assertAllCalled()
[docs] def test_051_set_invalid(self):[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00pool-file\npool-lvm\n' with self.assertRaises(SystemExit) as e: ['set', 'pool-lvm', '-o', 'prop=1'], self.assertEqual(e.exception.code, 1) self.assertAllCalled()