Added test for qvm-remove dependency reporting
This commit is contained in:
parent
ad2a6e3408
commit
47b4e86736
@ -21,6 +21,7 @@
|
|||||||
import qubesadmin.tests
|
import qubesadmin.tests
|
||||||
import qubesadmin.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesadmin.tools.qvm_remove
|
import qubesadmin.tools.qvm_remove
|
||||||
|
import unittest.mock
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_remove(qubesadmin.tests.QubesTestCase):
|
class TC_00_qvm_remove(qubesadmin.tests.QubesTestCase):
|
||||||
@ -33,3 +34,20 @@ class TC_00_qvm_remove(qubesadmin.tests.QubesTestCase):
|
|||||||
b'0\x00\n'
|
b'0\x00\n'
|
||||||
qubesadmin.tools.qvm_remove.main(['-f', 'some-vm'], app=self.app)
|
qubesadmin.tools.qvm_remove.main(['-f', 'some-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
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.")
|
||||||
|
Loading…
Reference in New Issue
Block a user