basic.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/python
  2. # vim: fileencoding=utf-8
  3. #
  4. # The Qubes OS Project, https://www.qubes-os.org/
  5. #
  6. # Copyright (C) 2014-2015
  7. # Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
  8. # Copyright (C) 2015 Wojtek Porczyk <woju@invisiblethingslab.com>
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License along
  21. # with this program; if not, write to the Free Software Foundation, Inc.,
  22. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23. #
  24. import multiprocessing
  25. import os
  26. import shutil
  27. import unittest
  28. import time
  29. from qubes.qubes import QubesVmCollection, QubesException, system_path
  30. import qubes.qubes
  31. import qubes.tests
  32. class TC_00_Basic(qubes.tests.SystemTestsMixin, unittest.TestCase):
  33. def test_000_create(self):
  34. vmname = self.make_vm_name('appvm')
  35. vm = self.qc.add_new_vm('QubesAppVm',
  36. name=vmname, template=self.qc.get_default_template())
  37. self.assertIsNotNone(vm)
  38. self.assertEqual(vm.name, vmname)
  39. self.assertEqual(vm.template, self.qc.get_default_template())
  40. vm.create_on_disk(verbose=False)
  41. with self.assertNotRaises(qubes.qubes.QubesException):
  42. vm.verify_files()
  43. class TC_01_Properties(qubes.tests.SystemTestsMixin, unittest.TestCase):
  44. def setUp(self):
  45. super(TC_01_Properties, self).setUp()
  46. self.vmname = self.make_vm_name('appvm')
  47. self.vm = self.qc.add_new_vm('QubesAppVm',
  48. name=self.vmname, template=self.qc.get_default_template())
  49. self.vm.create_on_disk(verbose=False)
  50. def test_000_rename(self):
  51. newname = self.make_vm_name('newname')
  52. self.assertEqual(self.vm.name, self.vmname)
  53. #TODO: change to setting property when implemented
  54. self.vm.set_name(newname)
  55. self.assertEqual(self.vm.name, newname)
  56. self.assertEqual(self.vm.dir_path,
  57. os.path.join(system_path['qubes_appvms_dir'], newname))
  58. self.assertEqual(self.vm.conf_file,
  59. os.path.join(self.vm.dir_path, newname + '.conf'))
  60. self.assertTrue(os.path.exists(
  61. os.path.join(self.vm.dir_path, "apps", newname + "-vm.directory")))
  62. # FIXME: set whitelisted-appmenus.list first
  63. self.assertTrue(os.path.exists(
  64. os.path.join(self.vm.dir_path, "apps", newname + "-firefox.desktop")))
  65. self.assertTrue(os.path.exists(
  66. os.path.join(os.getenv("HOME"), ".local/share/desktop-directories",
  67. newname + "-vm.directory")))
  68. self.assertTrue(os.path.exists(
  69. os.path.join(os.getenv("HOME"), ".local/share/applications",
  70. newname + "-firefox.desktop")))
  71. self.assertFalse(os.path.exists(
  72. os.path.join(os.getenv("HOME"), ".local/share/desktop-directories",
  73. self.vmname + "-vm.directory")))
  74. self.assertFalse(os.path.exists(
  75. os.path.join(os.getenv("HOME"), ".local/share/applications",
  76. self.vmname + "-firefox.desktop")))
  77. # vim: ts=4 sw=4 et