Added test for qvm-remove dependency reporting

This commit is contained in:
Marta Marczykowska-Górecka 2018-07-20 00:34:21 +02:00
parent ad2a6e3408
commit 47b4e86736
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B

View File

@ -21,6 +21,7 @@
import qubesadmin.tests
import qubesadmin.tests.tools
import qubesadmin.tools.qvm_remove
import unittest.mock
class TC_00_qvm_remove(qubesadmin.tests.QubesTestCase):
@ -33,3 +34,20 @@ class TC_00_qvm_remove(qubesadmin.tests.QubesTestCase):
b'0\x00\n'
qubesadmin.tools.qvm_remove.main(['-f', 'some-vm'], app=self.app)
self.assertAllCalled()
@unittest.mock.patch('qubesadmin.utils.vm_dependencies')
def test_100_dependencies(self, mock_dependencies):
self.app.expected_calls[
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.Remove', None, None)] = \
b'2\x00QubesVMInUseError\x00\x00An error occurred\x00'
mock_dependencies.return_value = \
[(None, 'default_template'), (self.app.domains['some-vm'], 'netvm')]
qubesadmin.tools.qvm_remove.main(['-f', 'some-vm'], app=self.app)
self.assertTrue(mock_dependencies.called,
"Dependencies check not called.")