qvm_prefs.py 2.2 KB

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