storage.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- encoding: utf8 -*-
  2. #
  3. # The Qubes OS Project, http://www.qubes-os.org
  4. #
  5. # Copyright (C) 2017 Marek Marczykowski-Górecki
  6. # <marmarek@invisiblethingslab.com>
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU Lesser General Public License as published by
  10. # the Free Software Foundation; either version 2.1 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Lesser General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Lesser General Public License along
  19. # with this program; if not, see <http://www.gnu.org/licenses/>.
  20. import qubesadmin.tests.vm
  21. class TestVMVolumes(qubesadmin.tests.vm.VMTestCase):
  22. def test_000_list_volumes(self):
  23. self.app.expected_calls[
  24. ('test-vm', 'admin.vm.volume.List', None, None)] = \
  25. b'0\x00root\nprivate\nvolatile\nmodules\n'
  26. self.assertEqual(set(self.vm.volumes.keys()),
  27. set(['root', 'private', 'volatile', 'modules']))
  28. self.assertAllCalled()
  29. def test_001_volume_get(self):
  30. self.app.expected_calls[
  31. ('test-vm', 'admin.vm.volume.List', None, None)] = \
  32. b'0\x00root\nprivate\nvolatile\nmodules\n'
  33. vol = self.vm.volumes['private']
  34. self.assertEqual(vol._vm, 'test-vm')
  35. self.assertEqual(vol._vm_name, 'private')
  36. # add it here, to raise exception if was called earlier
  37. self.app.expected_calls[
  38. ('test-vm', 'admin.vm.volume.Info', 'private', None)] = \
  39. b'0\x00pool=test-pool\nvid=some-id\n'
  40. self.assertEqual(vol.pool, 'test-pool')
  41. self.assertEqual(vol.vid, 'some-id')
  42. self.assertAllCalled()