def test_installs_as_expected(self, mock_InstallApplication, mock_RemoveApplication):
        app = self.get_application()
        base_path = 'apath'
        status_cb = MagicMock()
        complete_cb = MagicMock()

        thread = AsyncActionHandler("install", app, base_path, status_cb, complete_cb)
        thread.start()
        time.sleep(self.sleep_time)
        thread.join()

        mock_InstallApplication.assert_called_with(app, base_path, status_callback=status_cb)
        mock_InstallApplication.return_value.start.assert_called_with()
        self.assertFalse(mock_RemoveApplication.called)
        status_cb.assert_called_with("Complete")
        complete_cb.assert_called_with(True, "Success")
    def test_raises_errors_correctly(self, mock_InstallApplication, mock_RemoveApplication):
        app = self.get_application()
        base_path = 'apath'
        status_cb = MagicMock()
        complete_cb = MagicMock()
        mock_InstallApplication.return_value.start.side_effect = ActionHandlerException(1, "Kaboom")

        thread = AsyncActionHandler("install", app, base_path, status_cb, complete_cb)
        thread.start()
        time.sleep(self.sleep_time)
        thread.join()

        mock_InstallApplication.assert_called_with(app, base_path, status_callback=status_cb)
        mock_InstallApplication.return_value.start.assert_called_with()
        self.assertFalse(mock_RemoveApplication.called)
        status_cb.assert_called_with("Failed")
        complete_cb.assert_called_with(False, "Kaboom")
Exemple #3
0
 def process(self,
             id,
             base_install_path,
             action,
             status_callback=None,
             complete_callback=None):
     if action in ['install', 'remove', 'upgrade']:
         application = self.get_item(id)
         logger.info("Started {} of {} to {}".format(
             action, application.name, base_install_path))
         AsyncActionHandler(action,
                            application,
                            base_install_path,
                            status_callback=status_callback,
                            complete_callback=complete_callback).start()
     else:
         raise Exception("Nothing to do")
Exemple #4
0
    def test_removes_as_expected(self, mock_InstallApplication,
                                 mock_RemoveApplication):
        app = self.get_application()
        base_path = 'apath'
        status_cb = MagicMock()
        complete_cb = MagicMock()

        thread = AsyncActionHandler("remove", app, base_path, status_cb,
                                    complete_cb)
        thread.start()
        time.sleep(self.sleep_time)
        thread.join()

        mock_RemoveApplication.assert_called_with(app,
                                                  status_callback=status_cb)
        mock_RemoveApplication.return_value.start.assert_called_with()
        self.assertFalse(mock_InstallApplication.called)

        status_cb.assert_called_with("Complete")
        complete_cb.assert_called_with(True, "Success")
Exemple #5
0
    def test_raises_errors_correctly(self, mock_InstallApplication,
                                     mock_RemoveApplication):
        app = self.get_application()
        base_path = 'apath'
        status_cb = MagicMock()
        complete_cb = MagicMock()
        mock_InstallApplication.return_value.start.side_effect = ActionHandlerException(
            1, "Kaboom")

        thread = AsyncActionHandler("install", app, base_path, status_cb,
                                    complete_cb)
        thread.start()
        time.sleep(self.sleep_time)
        thread.join()

        mock_InstallApplication.assert_called_with(app,
                                                   base_path,
                                                   status_callback=status_cb)
        mock_InstallApplication.return_value.start.assert_called_with()
        self.assertFalse(mock_RemoveApplication.called)
        status_cb.assert_called_with("Failed")
        complete_cb.assert_called_with(False, "Kaboom")
 def test_thread_closes_after_exception(self, mock_InstallApplication, mock_RemoveApplication):
     thread = AsyncActionHandler("action", self.get_application(), '')
     thread.start()
     thread.join()
Exemple #7
0
 def test_thread_closes_after_exception(self, mock_InstallApplication,
                                        mock_RemoveApplication):
     thread = AsyncActionHandler("action", self.get_application(), '')
     thread.start()
     thread.join()