Exemple #1
0
    def test_check_provisioned_file_is_provisioned(self, mock_deprovision,
                                                   mock_read, mock_isfile):  # pylint: disable=unused-argument

        ph = ProvisionHandler()  # pylint: disable=invalid-name
        ph.osutil = Mock()
        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.check_provisioned_file())
        self.assertEqual(1, ph.osutil.is_current_instance_id.call_count)
        self.assertEqual(0,
                         deprovision_handler.run_changed_unique_id.call_count)
Exemple #2
0
    def test_provisioning_is_skipped_when_not_enabled(self, mock_conf):  # pylint: disable=unused-argument
        ph = ProvisionHandler()  # pylint: disable=invalid-name
        ph.osutil = DefaultOSUtil()
        ph.osutil.get_instance_id = Mock(
            return_value='B9F3C233-9913-9F42-8EB3-BA656DF32502')

        ph.check_provisioned_file = Mock()
        ph.report_ready = Mock()
        ph.write_provisioned = Mock()

        ph.run()

        self.assertEqual(0, ph.check_provisioned_file.call_count)
        self.assertEqual(1, ph.report_ready.call_count)
        self.assertEqual(1, ph.write_provisioned.call_count)
Exemple #3
0
 def test_check_provisioned_file_not_provisioned(self, mock_isfile):  # pylint: disable=unused-argument
     ph = ProvisionHandler()  # pylint: disable=invalid-name
     self.assertFalse(ph.check_provisioned_file())