diff options
author | Ćukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> | 2017-09-04 10:27:07 +0200 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2017-09-04 09:38:24 +0000 |
commit | 185ceb32fea5d5c2a43d7b6ee2a40228489055f4 (patch) | |
tree | 2e1c9cc42510c4a922cf63fa265ec0e1945ec14b /tests/pa | |
parent | 43bdf9debe5377216aed0086bff2aad864f6ba82 (diff) | |
download | vyos-walinuxagent-185ceb32fea5d5c2a43d7b6ee2a40228489055f4.tar.gz vyos-walinuxagent-185ceb32fea5d5c2a43d7b6ee2a40228489055f4.zip |
Import patches-unapplied version 2.2.16-0ubuntu1 to ubuntu/artful-proposed
Imported using git-ubuntu import.
Changelog parent: 43bdf9debe5377216aed0086bff2aad864f6ba82
New changelog entries:
* New upstream release (LP: #1714299).
Diffstat (limited to 'tests/pa')
-rw-r--r-- | tests/pa/test_provision.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/pa/test_provision.py b/tests/pa/test_provision.py index 0446442..7045fcc 100644 --- a/tests/pa/test_provision.py +++ b/tests/pa/test_provision.py @@ -53,6 +53,24 @@ class TestProvision(AgentTestCase): data = DefaultOSUtil().decode_customdata(base64data) fileutil.write_file(tempfile.mktemp(), data) + @patch('azurelinuxagent.common.conf.get_provision_enabled', + return_value=False) + def test_provisioning_is_skipped_when_not_enabled(self, mock_conf): + ph = ProvisionHandler() + ph.osutil = DefaultOSUtil() + ph.osutil.get_instance_id = Mock( + return_value='B9F3C233-9913-9F42-8EB3-BA656DF32502') + + ph.is_provisioned = Mock() + ph.report_ready = Mock() + ph.write_provisioned = Mock() + + ph.run() + + ph.is_provisioned.assert_not_called() + ph.report_ready.assert_called_once() + ph.write_provisioned.assert_called_once() + @patch('os.path.isfile', return_value=False) def test_is_provisioned_not_provisioned(self, mock_isfile): ph = ProvisionHandler() @@ -64,33 +82,37 @@ class TestProvision(AgentTestCase): @patch('azurelinuxagent.pa.deprovision.get_deprovision_handler') def test_is_provisioned_is_provisioned(self, mock_deprovision, mock_read, mock_isfile): + ph = ProvisionHandler() ph.osutil = Mock() - ph.osutil.get_instance_id = \ - Mock(return_value="B9F3C233-9913-9F42-8EB3-BA656DF32502") + ph.osutil.is_current_instance_id = Mock(return_value=True) ph.write_provisioned = Mock() deprovision_handler = Mock() mock_deprovision.return_value = deprovision_handler self.assertTrue(ph.is_provisioned()) + ph.osutil.is_current_instance_id.assert_called_once() deprovision_handler.run_changed_unique_id.assert_not_called() @patch('os.path.isfile', return_value=True) @patch('azurelinuxagent.common.utils.fileutil.read_file', - side_effect=["Value"]) + return_value="B9F3C233-9913-9F42-8EB3-BA656DF32502") @patch('azurelinuxagent.pa.deprovision.get_deprovision_handler') def test_is_provisioned_not_deprovisioned(self, mock_deprovision, mock_read, mock_isfile): ph = ProvisionHandler() ph.osutil = Mock() + ph.osutil.is_current_instance_id = Mock(return_value=False) + ph.report_ready = Mock() ph.write_provisioned = Mock() deprovision_handler = Mock() mock_deprovision.return_value = deprovision_handler self.assertTrue(ph.is_provisioned()) + ph.osutil.is_current_instance_id.assert_called_once() deprovision_handler.run_changed_unique_id.assert_called_once() if __name__ == '__main__': |