From 47b4e8673601fa95f13a0b60de58de265a1e67ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Fri, 20 Jul 2018 00:34:21 +0200 Subject: [PATCH] Added test for qvm-remove dependency reporting --- qubesadmin/tests/tools/qvm_remove.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/qubesadmin/tests/tools/qvm_remove.py b/qubesadmin/tests/tools/qvm_remove.py index 38995b3..3e50e95 100644 --- a/qubesadmin/tests/tools/qvm_remove.py +++ b/qubesadmin/tests/tools/qvm_remove.py @@ -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.")