qubesvm.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/usr/bin/python2 -O
  2. import sys
  3. import unittest
  4. import qubes
  5. import qubes.vm.qubesvm
  6. import qubes.tests
  7. class TestProp(object):
  8. __name__ = 'testprop'
  9. class TestVM(object):
  10. def __init__(self):
  11. self.running = False
  12. self.installed_by_rpm = False
  13. def is_running(self):
  14. return self.running
  15. class TC_00_setters(qubes.tests.QubesTestCase):
  16. def setUp(self):
  17. self.vm = TestVM()
  18. self.prop = TestProp()
  19. def test_000_setter_qid(self):
  20. self.assertEqual(
  21. qubes.vm.qubesvm._setter_qid(self.vm, self.prop, 5), 5)
  22. def test_001_setter_qid_lt_0(self):
  23. with self.assertRaises(ValueError):
  24. qubes.vm.qubesvm._setter_qid(self.vm, self.prop, -1)
  25. def test_002_setter_qid_gt_max(self):
  26. with self.assertRaises(ValueError):
  27. qubes.vm.qubesvm._setter_qid(self.vm, self.prop, qubes.MAX_QID + 5)
  28. def test_010_setter_name(self):
  29. self.assertEqual(
  30. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'test_name-1'),
  31. 'test_name-1')
  32. def test_011_setter_name_longer_than_31(self):
  33. with self.assertRaises(ValueError):
  34. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 't' * 32)
  35. def test_012_setter_name_illegal_character(self):
  36. with self.assertRaises(ValueError):
  37. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'test#')
  38. def test_013_setter_name_first_not_letter(self):
  39. with self.assertRaises(ValueError):
  40. qubes.vm.qubesvm._setter_name(self.vm, self.prop, '1test')
  41. def test_014_setter_name_running(self):
  42. self.vm.running = True
  43. with self.assertRaises(qubes.QubesException):
  44. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'testname')
  45. def test_015_setter_name_installed_by_rpm(self):
  46. self.vm.installed_by_rpm = True
  47. with self.assertRaises(qubes.QubesException):
  48. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'testname')
  49. @unittest.skip('test not implemented')
  50. def test_020_setter_kernel(self):
  51. pass
  52. class TC_90_QubesVM(qubes.tests.QubesTestCase):
  53. @unittest.skip('test not implemented')
  54. def test_000_init(self):
  55. pass