summaryrefslogtreecommitdiff
path: root/tests/pa
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2017-07-03 13:44:00 +0200
committerusd-importer <ubuntu-server@lists.ubuntu.com>2017-07-03 12:23:41 +0000
commit70c0ea1ac879b2e1cba0a8edb1f3fbe82652413b (patch)
treef168bb289117feb1c0d5b2c73604b44e85b064e2 /tests/pa
parent68754fe67f1b3da2e6ca45885641941b3229698a (diff)
parent63aafec1b1a480947da7d5579c3ffc66b8fe5bdb (diff)
downloadvyos-walinuxagent-70c0ea1ac879b2e1cba0a8edb1f3fbe82652413b.tar.gz
vyos-walinuxagent-70c0ea1ac879b2e1cba0a8edb1f3fbe82652413b.zip
Import patches-applied version 2.2.14-0ubuntu1 to applied/ubuntu/artful-proposed
Imported using git-ubuntu import. Changelog parent: 68754fe67f1b3da2e6ca45885641941b3229698a Unapplied parent: 63aafec1b1a480947da7d5579c3ffc66b8fe5bdb New changelog entries: * New upstream release (LP: #1701350). * debian/copyright: - Refreshed copyright content.
Diffstat (limited to 'tests/pa')
-rw-r--r--tests/pa/test_deprovision.py38
1 files changed, 34 insertions, 4 deletions
diff --git a/tests/pa/test_deprovision.py b/tests/pa/test_deprovision.py
index c4cd9b4..b2f7f0c 100644
--- a/tests/pa/test_deprovision.py
+++ b/tests/pa/test_deprovision.py
@@ -15,6 +15,7 @@
# Requires Python 2.4+ and Openssl 1.0+
#
+import signal
import tempfile
import azurelinuxagent.common.utils.fileutil as fileutil
@@ -25,16 +26,44 @@ from tests.tools import *
class TestDeprovision(AgentTestCase):
+ @patch('signal.signal')
+ @patch('azurelinuxagent.common.osutil.get_osutil')
+ @patch('azurelinuxagent.common.protocol.get_protocol_util')
+ @patch('azurelinuxagent.pa.deprovision.default.read_input')
+ def test_confirmation(self,
+ mock_read, mock_protocol, mock_util, mock_signal):
+ dh = DeprovisionHandler()
+
+ dh.setup = Mock()
+ dh.setup.return_value = ([], [])
+ dh.do_actions = Mock()
+
+ # Do actions if confirmed
+ mock_read.return_value = "y"
+ dh.run()
+ self.assertEqual(1, dh.do_actions.call_count)
+
+ # Skip actions if not confirmed
+ mock_read.return_value = "n"
+ dh.run()
+ self.assertEqual(1, dh.do_actions.call_count)
+
+ # Do actions if forced
+ mock_read.return_value = "n"
+ dh.run(force=True)
+ self.assertEqual(2, dh.do_actions.call_count)
+
@patch("azurelinuxagent.pa.deprovision.default.DeprovisionHandler.cloud_init_dirs")
@patch("azurelinuxagent.pa.deprovision.default.DeprovisionHandler.cloud_init_files")
def test_del_cloud_init_without_once(self,
mock_files,
mock_dirs):
deprovision_handler = get_deprovision_handler("","","")
- deprovision_handler.del_cloud_init([], [], include_once=False)
+ deprovision_handler.del_cloud_init([], [],
+ include_once=False, deluser=False)
mock_dirs.assert_called_with(include_once=False)
- mock_files.assert_called_with(include_once=False)
+ mock_files.assert_called_with(include_once=False, deluser=False)
@patch("signal.signal")
@patch("azurelinuxagent.common.protocol.get_protocol_util")
@@ -59,10 +88,11 @@ class TestDeprovision(AgentTestCase):
mock_files.return_value = files
deprovision_handler = get_deprovision_handler("","","")
- deprovision_handler.del_cloud_init(warnings, actions)
+ deprovision_handler.del_cloud_init(warnings, actions,
+ deluser=True)
mock_dirs.assert_called_with(include_once=True)
- mock_files.assert_called_with(include_once=True)
+ mock_files.assert_called_with(include_once=True, deluser=True)
self.assertEqual(len(warnings), 0)
self.assertEqual(len(actions), 2)