Exemplo n.º 1
0
    def test_is_provisioned_not_deprovisioned(self,
            mock_deprovision, mock_read, mock_isfile):

        ph = ProvisionHandler()
        ph.osutil = Mock()
        ph.write_provisioned = Mock()

        deprovision_handler = Mock()
        mock_deprovision.return_value = deprovision_handler

        self.assertTrue(ph.is_provisioned())
        deprovision_handler.run_changed_unique_id.assert_called_once()
Exemplo n.º 2
0
    def test_is_provisioned_not_deprovisioned(self, mock_deprovision,
                                              mock_read, mock_isfile):

        ph = ProvisionHandler()
        ph.osutil = Mock()
        ph.write_provisioned = Mock()

        deprovision_handler = Mock()
        mock_deprovision.return_value = deprovision_handler

        self.assertTrue(ph.is_provisioned())
        deprovision_handler.run_changed_unique_id.assert_called_once()
Exemplo n.º 3
0
    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.write_provisioned = Mock()

        deprovision_handler = Mock()
        mock_deprovision.return_value = deprovision_handler

        self.assertTrue(ph.is_provisioned())
        deprovision_handler.run_changed_unique_id.assert_not_called()
Exemplo n.º 4
0
    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.write_provisioned = Mock()

        deprovision_handler = Mock()
        mock_deprovision.return_value = deprovision_handler

        self.assertTrue(ph.is_provisioned())
        deprovision_handler.run_changed_unique_id.assert_not_called()
Exemplo n.º 5
0
    def test_is_provisioned_is_provisioned(self,
            mock_deprovision, mock_read, mock_isfile):

        ph = ProvisionHandler()
        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.is_provisioned())
        self.assertEqual(1, ph.osutil.is_current_instance_id.call_count)
        self.assertEqual(0, deprovision_handler.run_changed_unique_id.call_count)
Exemplo n.º 6
0
    def test_is_provisioned_is_provisioned(self,
            mock_deprovision, mock_read, mock_isfile):

        ph = ProvisionHandler()
        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.is_provisioned())
        self.assertEqual(1, ph.osutil.is_current_instance_id.call_count)
        self.assertEqual(0, deprovision_handler.run_changed_unique_id.call_count)
Exemplo n.º 7
0
    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()
Exemplo n.º 8
0
    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()

        self.assertEqual(0, ph.is_provisioned.call_count)
        self.assertEqual(1, ph.report_ready.call_count)
        self.assertEqual(1, ph.write_provisioned.call_count)
Exemplo n.º 9
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)
Exemplo n.º 10
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)