qvm_prefs.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #
  2. # The Qubes OS Project, https://www.qubes-os.org/
  3. #
  4. # Copyright (C) 2015 Joanna Rutkowska <joanna@invisiblethingslab.com>
  5. # Copyright (C) 2015 Wojtek Porczyk <woju@invisiblethingslab.com>
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program; if not, write to the Free Software Foundation, Inc.,
  19. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. #
  21. import qubes
  22. import qubes.tools.qvm_prefs
  23. import qubes.tests
  24. @qubes.tests.skipUnlessDom0
  25. class TC_00_qvm_prefs(
  26. qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase):
  27. def test_000_list(self):
  28. self.assertEqual(0, qubes.tools.qvm_prefs.main([
  29. '--qubesxml', qubes.tests.XMLPATH, 'dom0']))
  30. def test_001_no_vm(self):
  31. with self.assertRaises(SystemExit):
  32. qubes.tools.qvm_prefs.main([
  33. '--qubesxml', qubes.tests.XMLPATH])
  34. def test_002_set_property(self):
  35. self.assertEqual(0, qubes.tools.qvm_prefs.main([
  36. '--qubesxml', qubes.tests.XMLPATH, 'dom0',
  37. 'default_user', 'testuser']))
  38. self.assertEqual('testuser',
  39. qubes.Qubes(qubes.tests.XMLPATH).domains['dom0'].default_user)
  40. def test_003_invalid_property(self):
  41. with self.assertRaises(SystemExit):
  42. qubes.tools.qvm_prefs.main([
  43. '--qubesxml', qubes.tests.XMLPATH, 'dom0',
  44. 'no_such_property'])
  45. def test_004_set_invalid_property(self):
  46. with self.assertRaises(SystemExit):
  47. qubes.tools.qvm_prefs.main([
  48. '--qubesxml', qubes.tests.XMLPATH, 'dom0',
  49. 'no_such_property', 'value'])